<template>
    <div class="basis-info">
        <div class="basis_content">
            <Form ref="basicTypeForm" :model="basicTypeForm" :rules="basicTypeFormValidate" v-bind:disabled="this.typeCode == '0'"  :label-width="150">
                <!--基本信息   -->
                <Card>
                <div class="common_br">
                    <h2 class="common_channel_title" >基本信息</h2>
                    <div class="common_content">
                        <Row>
                            <Col span="8">
                                <FormItem label="车商代码"  prop="channelCode" >
                                    <Input v-model.trim="basicTypeForm.channelCode"  readonly="readonly"  class="w200" placeholder="系统自动生成"/>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="车商名称" prop="channelFullName">
                                    <Input v-model.trim="basicTypeForm.channelFullName"   class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>


                            <Col span="8">
                                <FormItem label="合作商名称" prop="channelName" style="width: 350px"  >
                                    <!--<Select v-model="basicTypeForm.channelId" filterable  placeholder="请选择" style="width: 200px" class="s1"  @on-change="getChannelInfoById" v-bind:disabled="this.typeCode2 == '2' && this.OldStatus !='06'" clearable>
                                        <Option v-for="(item,index) in channelData" :value="item.id" :label="item.channelFullName"  :key="index" ></Option>
                                    </Select>-->
                                    <Input v-model.trim="basicTypeForm.channelName"   class="w200"  placeholder="请输入" disabled/>
                                </FormItem>
                            </Col>

                        </Row>

                        <Row>
                            <Col span="8">
                                <FormItem label="统一社会信用代码" prop="socUniCrtCode" >
                                    <Input v-model.trim="basicTypeForm.socUniCrtCode" class="w200" @on-blur="checkBlack" placeholder="请输入" v-bind:disabled="this.typeCode2 == '2' && this.OldStatus !='06'"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="法人" prop="legalPerson">
                                    <Input v-model.trim="basicTypeForm.legalPerson"   class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="法人身份证号" prop="legalPersonIdCard">
                                    <Input v-model.trim="basicTypeForm.legalPersonIdCard"    class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>
                        </Row>

                        <Row>
                            <Col span="8">
                                <FormItem label="法人电话" prop="legalPersonTel">
                                    <Input v-model.trim="basicTypeForm.legalPersonTel"    class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="实际控制人" prop="actualController">
                                    <Input v-model.trim="basicTypeForm.actualController"   class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="实际控制人电话" prop="actualControllerTel">
                                    <Input v-model.trim="basicTypeForm.actualControllerTel"   class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>

                        </Row>

                        <Row>
                            <Col span="8">
                                <FormItem label="实际控制人身份证号" prop="actualControllerIdCard">
                                    <Input v-model.trim="basicTypeForm.actualControllerIdCard"   class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="公司人数" prop="companiesNumber">
                                    <InputNumber :max="1000" :min="0" v-model="basicTypeForm.companiesNumber" class="w200" ></InputNumber>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="经营场所面积(平方米)" prop="businessArea">
                                    <Input v-model.trim="basicTypeForm.businessArea"    class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>


                        </Row>

                        <Row>

                            <Col span="8">
                                <FormItem label="注册地址" prop="channelAddressValue">
                                    <Cascader :load-data="locationChange" :data="location" v-model="basicTypeForm.channelAddressValue" placeholder="下拉选择省市"  class="w200" @on-change="onChangeLocation"  :clearable="false" >
                                    </Cascader>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="请输入详细地址" prop="channelAddressDetail">
                                    <Input v-model.trim="basicTypeForm.channelAddressDetail" placeholder="请输入" class="w200"  @on-blur="onBlurLocation"/>
                                </FormItem>
                            </Col>

                            <!--<Col span="5" offset="1">
                                <Button type="primary" :disabled="!canOpenMapModal" @click="openMapModal">获取经纬度</Button>
                            </Col>-->

                           <!-- <Col span="8">
                                <FormItem label="地址经纬度" prop="longitudeLatitude">
                                    <Input v-model.trim="basicTypeForm.longitudeLatitude"    placeholder="输入详细地址后带出" class="w200"/>
                                </FormItem>
                            </Col>-->
                            <Col span="8">
                                <FormItem label="上线日期" prop="onlineDate" >
                                    <Date-picker type="date" v-model="basicTypeForm.onlineDate" class="w200"  placeholder="选择日期" ></Date-picker>
                                </FormItem>
                            </Col>


                        </Row>

                        <Row>

                            <Col span="8">
                                <FormItem label="地址经度" prop="longitude">
                                    <Input v-model.trim="basicTypeForm.longitude"    class="w200"  placeholder="输入地址后自动带入"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="地址纬度" prop="latitude">
                                    <Input v-model.trim="basicTypeForm.latitude"    class="w200"  placeholder="输入地址后自动带入"/>
                                </FormItem>
                            </Col>



                          <!--  <Col span="8">
                                <FormItem label="经纬度范围（km）" prop="longitudeLatitudeRange" >
                                    <Input v-model.trim="basicTypeForm.longitudeLatitudeRange"    class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>-->


                            <Col span="8">
                                <FormItem label="车商类型" prop="cardealType">
                                    <RadioGroup v-model="basicTypeForm.cardealType" >
                                        <Radio label="1">4S店</Radio>
                                        <Radio label="0">综合汽贸</Radio>
                                    </RadioGroup>
                                </FormItem>
                            </Col>

                        </Row>

                        <Row>

                            <Col span="8">
                                <FormItem label="经纬度是否控制" prop="longitudeLatitudeSwitch">
                                    <RadioGroup v-model="basicTypeForm.longitudeLatitudeSwitch"     >
                                        <Radio label="1">是</Radio>
                                        <Radio label="0">否</Radio>
                                    </RadioGroup>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="账户信息" prop="accountInfo" >
                                    <RadioGroup v-model="basicTypeForm.accountInfo" >
                                        <Radio label="1" v-bind:disabled="this.accountSwitch == 1">有</Radio>
                                        <Radio label="0" v-bind:disabled="this.accountSwitch == 1">无</Radio>
                                    </RadioGroup>
                                </FormItem>
                            </Col>


                            <Col span="8">
                                <FormItem label="主营品牌" prop="mainBrand">
                                    <Tree :data="baseData"  ref="baseTree" show-checkbox v-model="basicTypeForm.mainBrand" style="height:200px;overflow-y:auto"  multiple> </Tree>
                                </FormItem>
                            </Col>


                        </Row>

                    </div>
                </div>
                </Card>

                <Card>
                <div class="common_br">
                    <h2 class="common_channel_title" >资质信息</h2>
                    <div class="common_content">
                        <Row>

                            <Col span="8">
                                <FormItem label="业务类型" prop="businessType">
                                    <Checkbox-group  v-model="basicTypeForm.businessType"  @on-change="carBusinessType"   >
                                        <Checkbox label="01" v-bind:disabled="oldCar">新车</Checkbox>
                                        <Checkbox label="02" v-bind:disabled="newCar">二手车</Checkbox>
                                    </Checkbox-group>
                                </FormItem>
                            </Col>
                        </Row>

                        <Row>

                        <Col span="8">
                            <FormItem label="实收资本(万元)" prop="subscribedCapital">
                                <Input v-model.trim="basicTypeForm.subscribedCapital"   class="w200"  placeholder="请输入"/>
                            </FormItem>
                        </Col>


                            <Col span="8">
                                <FormItem label="注册资金(万元)" prop="registeredCapital">
                                    <Input v-model.trim="basicTypeForm.registeredCapital"    class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>

                        <Col span="8">
                            <FormItem label="GPS厂商授权" prop="gpsVendorAuthor">
                                <Select v-model="basicTypeForm.gpsVendorAuthor"     multiple allow-create @on-create="handgps_vendor_author" style="width: 200px" @on-change="changeGPS">
                                    <Option :value="item.value" v-for="(item,index) in gpsvendorauthorList" :key="index"> {{item.title}}</Option>
                                </Select>
                            </FormItem>
                        </Col>

                        </Row>

                        <Row>
                            <Col span="8">
                                <FormItem label="资产净值(元)" prop="netAssetValue">
                                    <Input v-model.trim="basicTypeForm.netAssetValue"   class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="经营年限(年)" prop="businessLife">
                                    <Input v-model.trim="basicTypeForm.businessLife"   class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="GPS安装方式" prop="gpsInstalMode">
                                    <Select v-model="basicTypeForm.gpsInstalMode"  style="width: 200px" >
                                        <Option :value="item.value" v-for="(item,index) in gpsinstalmodeList" :key="index"> {{item.title}}</Option>
                                    </Select>
                                </FormItem>
                            </Col>


                        </Row>

                        <Row>
                            <Col span="8">
                                <FormItem label="资产负债率(%)" prop="assetLiabilityRatio">
                                    <Input v-model.trim="basicTypeForm.assetLiabilityRatio"   maxlength="2" class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="注册日期" prop="registrationDate" >
                                    <Date-picker type="date" v-model="basicTypeForm.registrationDate"    class="w200"  placeholder="选择日期" ></Date-picker>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="上一年度经营利润(元)" prop="operatingProfit">
                                    <Input v-model.trim="basicTypeForm.operatingProfit"   class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>


                        </Row>

                        <Row>
                            <Col span="8">
                                <FormItem label="业绩(单)" prop="achievement">
                                    <Input v-model.trim="basicTypeForm.achievement"   class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="利润率增长率(%)" prop="proGrowthRate">
                                    <Input v-model.trim="basicTypeForm.proGrowthRate"   maxlength="2" class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="销售收入增长率(%)" prop="saleIncreaseRate">
                                    <Input v-model.trim="basicTypeForm.saleIncreaseRate"   maxlength="2" class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>
                        </Row>

                        <Row>
                            <Col span="8">
                                <FormItem label="流动比率(%)" prop="currentRatio">
                                    <Input v-model.trim="basicTypeForm.currentRatio"    maxlength="2" class="w200"  placeholder="请输入"/>
                                </FormItem>
                            </Col>
                        </Row>

                    </div>
                </div>
                </Card>

                <!--<div style="padding: 10px;">
                    <Button type="primary" @click="addNewCar" v-bind:disabled="this.viewNewCar == '0'" >新车</Button>
                    <Button type="primary"@click="addOldCar" v-bind:disabled="this.viewOldCar == '0'">二手车</Button>
                </div>-->
                <div v-if="this.showGroupNewCar=='1'">
                    <Card>
                    <div class="common_br">
                        <h2 class="common_channel_title" >新车优质信息</h2>
                        <div class="common_content" style="padding-left: 16%;">
                            <Row>
                                <Col span="12">
                                    <FormItem label="优质等级" prop="qualityGrade"  >
                                        <Select v-model="basicTypeForm.qualityGrade"  placeholder="优质等级" class="w200" @on-change="checkQualityGrade"  >
                                            <Option :value="item.value" v-for="(item,index) in qualityGradeList" :key="index"> {{item.title}}</Option>
                                        </Select>
                                    </FormItem>
                                </Col>

                                <Col span="12">
                                    <Form-item label="有效期" prop="validDate" :rules="Number(basicTypeForm.qualityGrade) != 5?validDate:notValidDate">
                                        <DatePicker v-model="basicTypeForm.validDate" type="daterange" format="yyyy-MM-dd"  placeholder="选择起止时间"
                                                    style="width: 200px">
                                        </DatePicker>
                                    </Form-item>
                                </Col>
                            </Row>
                        </div>
                    </div>
                    <div class="common_br">
                        <h2 class="common_channel_title" >新车风控信息</h2>
                        <div class="common_content" style="padding-left: 16%;">
                            <Row>
                                <Col span="12">
                                    <FormItem label="车辆类型" prop="carType">
                                        <Checkbox-group  v-model="basicTypeForm.carType"  @on-change="checkAllNewCar" >
                                            <Checkbox label="00" v-bind:disabled="this.businessTypeSwitch0 == '0'">乘用车</Checkbox>
                                            <Checkbox label="01" v-bind:disabled="this.businessTypeSwitch1 == '1'">LCV</Checkbox>
                                            <Checkbox label="02" v-bind:disabled="this.businessTypeSwitch2 == '2'">中卡</Checkbox>
                                            <Checkbox label="03" v-bind:disabled="this.businessTypeSwitch3 == '3'">重卡</Checkbox>
                                        </Checkbox-group>
                                    </FormItem>
                                </Col>

                                <Col span="12">
                                    <FormItem label="城市经理" prop="customerManager" v-if="!basicTypeForm.id">
                                        <Select v-model="basicTypeForm.customerManager"    placeholder="城市经理" class="w200">
                                            <Option v-for="(item,index) in salesManData" :value="item.username" :label="item.userRealName" :key="index" >
                                            </Option>
                                        </Select>
                                    </FormItem>
                                </Col>


                            </Row>
                            <Row>
                                <Col span="12">
                                    <FormItem label="评级" prop="channelGrade" >
                                        <Select v-model="basicTypeForm.channelGrade"    placeholder="评级" class="w200">
                                            <Option value="1">A</Option>
                                            <Option value="2">B</Option>
                                            <Option value="3">C</Option>
                                            <Option value="4">D</Option>
                                        </Select>
                                    </FormItem>
                                </Col>

                                <Col span="12">
                                    <FormItem label="保证金(元)" prop="channelDeposit">
                                        <Input v-model.trim="basicTypeForm.channelDeposit"    class="w200"  placeholder="请输入"/>
                                    </FormItem>
                                </Col>
                            </Row>

                            <Row>
                                <!-- 签放额度判断 -->
                                <Col span="12">
                                    <FormItem label="是否控制额度" prop="isLimitPut">
                                        <RadioGroup v-model="basicTypeForm.isLimitPut"  @on-change="checkLimitPut()"  >
                                            <Radio label="1">是</Radio>
                                            <Radio label="0">否</Radio>
                                        </RadioGroup>
                                    </FormItem>
                                </Col>

                                <!-- 先放后抵额度判断 -->
                                <Col span="12">
                                    <FormItem label="是否控制额度" prop="isLimitPledge">
                                        <RadioGroup v-model="basicTypeForm.isLimitPledge"  @on-change="checkLimitPut()" >
                                            <Radio label="1">是</Radio>
                                            <Radio label="0">否</Radio>
                                        </RadioGroup>
                                    </FormItem>
                                </Col>
                            </Row>

                            <Row>
                                <Col span="12">
                                    <FormItem label="签放额度(元)" prop="limitPut" :rules="Number(basicTypeForm.isLimitPut)?limitPut:notLimitPut">
                                        <Input v-model.trim="basicTypeForm.limitPut"  class="w200"   placeholder="请输入"/>
                                    </FormItem>
                                </Col>

                                <Col span="12">
                                    <FormItem label="先放后抵额度(元)" prop="limitPledge" :rules="Number(basicTypeForm.isLimitPledge)?limitPledge:notLimitPledge">
                                        <Input v-model.trim="basicTypeForm.limitPledge"   class="w200"  placeholder="请输入"/>
                                    </FormItem>
                                </Col>
                            </Row>

                            <Row>
                                <!-- 签放额度 -->
                                <Col span="12">
                                    <FormItem label="临时额度(元)" prop="temporaryLimitPut"  >
                                        <Input v-model.trim="basicTypeForm.temporaryLimitPut"    class="w200"  placeholder="请输入"  @on-change="checkdate()"/>
                                    </FormItem>
                                </Col>

                                <!-- 先放后抵额度 -->
                                <Col span="12">
                                    <FormItem label="临时额度(元)" prop="temporaryLimitPledge"  >
                                        <Input v-model.trim="basicTypeForm.temporaryLimitPledge"   class="w200"  placeholder="请输入"  @on-change="checkdate()"/>
                                    </FormItem>
                                </Col>
                            </Row>

                            <Row>
                                <!-- 签放额度有效期 -->
                                <Col span="12">
                                    <Form-item label="有效期" prop="limitPutTime" :rules="Number(newCarDate1) != 1?notNewCarLimitPutTime:newCarLimitPutTime">
                                        <Date-picker type="date" v-model="basicTypeForm.limitPutTime"    class="w200"  placeholder="选择日期" ></Date-picker>
                                    </Form-item>
                                </Col>

                                <!-- 先放后抵额度有效期 -->
                                <Col span="12">
                                    <Form-item label="有效期" prop="limitPledgeTime" :rules="Number(newCarDate2) != 1?notNewCarLimitPutTime:newCarLimitPutTime">
                                        <Date-picker type="date" v-model="basicTypeForm.limitPledgeTime"   class="w200"  placeholder="选择日期" ></Date-picker>
                                    </Form-item>
                                </Col>
                            </Row>

                            <Row>
                                <!-- 签放额度占用 -->
                                <Col span="12">
                                    <FormItem label="占用额度(元)" prop="limitPutTake">
                                        <Input v-model.trim="basicTypeForm.limitPutTake" readonly="readonly"   class="w200"  placeholder="系统自动计算"/>
                                    </FormItem>
                                </Col>

                                <!-- 先放后抵额度占用 -->
                                <Col span="12">
                                    <FormItem label="占用额度(元)" prop="limitPledgeTake">
                                        <Input v-model.trim="basicTypeForm.limitPledgeTake"  readonly="readonly"  class="w200"  placeholder="系统自动计算"/>
                                    </FormItem>
                                </Col>

                            </Row>

                            <Row>
                                <!-- 剩余签放额度 -->
                                <Col span="12">
                                    <FormItem label="剩余额度(元)" prop="limitPutResidue">
                                        <Input v-model.trim="basicTypeForm.limitPutResidue"  readonly="readonly"  class="w200"  placeholder="系统自动计算"/>
                                    </FormItem>
                                </Col>

                                <!-- 剩余先放后抵额度 -->
                                <Col span="12">
                                    <FormItem label="剩余额度(元)" prop="limitPledgeResidue">
                                        <Input v-model.trim="basicTypeForm.limitPledgeResidue"  readonly="readonly"  class="w200"  placeholder="系统自动计算"/>
                                    </FormItem>
                                </Col>
                            </Row>
                        </div>

                        <div class="common_br">
                            <h2 class="common_channel_title" >新车授权区域/授权车型</h2>
                            <div class="common_content" style="padding-left: 16%;">
                                <Row>
                                    <Row>
                                        <Col span="12">
                                            <FormItem label="区域是否生效" prop="authRegionSwitch">
                                                <RadioGroup v-model="basicTypeForm.authRegionSwitch"   >
                                                    <Radio label="1">是</Radio>
                                                    <Radio label="0">否</Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </Col>

                                        <Col span="12">
                                            <FormItem label="车型是否生效" prop="authVehicleTypeSwitch">
                                                <RadioGroup v-model="basicTypeForm.authVehicleTypeSwitch"    >
                                                    <Radio label="1">是</Radio>
                                                    <Radio label="0">否</Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </Col>
                                    </Row>

                                    <Row>
                                            <Col span="12" style="height:200px;overflow-y:auto" >
                                                <FormItem label="" prop="mainArea">
                                                    <Tree :data="areasData" ref="tree"  show-checkbox v-model="basicTypeForm.mainArea"  multiple > </Tree>
                                                </FormItem>
                                            </Col>

                                            <Col span="12" style="height:200px;overflow-y:auto">
                                                <FormItem label="" prop="mainCar">
                                                    <Tree :data="carsData" ref="carstree" show-checkbox v-model="basicTypeForm.mainCar" multiple  > </Tree>
                                                </FormItem>
                                            </Col>

                                    </Row>
                                </Row>
                                <div>
                                    <a class="select-clear" @click="showAreasNewCar">选择渠道展业区域查看</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    </Card>
                </div>

                <div v-if="this.showGroupOldCar=='1'">
                    <Card>
                    <div class="common_br">
                        <h2 class="common_channel_title" >二手车优质信息</h2>
                        <div class="common_content" style="padding-left: 16%;">
                            <Row>
                                <Col span="12">
                                    <FormItem label="优质等级" prop="qualityGradeOld" >
                                        <Select v-model="basicTypeForm.qualityGradeOld" placeholder="优质等级" class="w200" @on-change="checkQualityGrade()">
                                            <Option :value="item.value" v-for="(item,index) in qualityGradeList" :key="index"> {{item.title}}</Option>
                                        </Select>
                                    </FormItem>
                                </Col>

                                <Col span="12">
                                    <Form-item label="有效期" prop="validDateOld" :rules="Number(basicTypeForm.qualityGradeOld) != 5?validDateOld:notValidDateOld">
                                        <DatePicker v-model="basicTypeForm.validDateOld" type="daterange" format="yyyy-MM-dd"  placeholder="选择起止时间"
                                                    style="width: 200px">
                                        </DatePicker>
                                    </Form-item>
                                </Col>
                            </Row>
                        </div>
                    </div>
                    <div class="common_br">
                        <h2 class="common_channel_title" >二手车风控信息</h2>
                        <div class="common_content" style="padding-left: 16%;">
                            <Row>
                                <Col span="12">
                                    <FormItem label="车辆类型" prop="carTypeOld">
                                        <Checkbox-group  v-model="basicTypeForm.carTypeOld" @on-change="checkAllOldCar">
                                            <Checkbox label="00" v-bind:disabled="this.carTypeSwitch0 == '0'">乘用车</Checkbox>
                                            <Checkbox label="01" v-bind:disabled="this.carTypeSwitch1 == '1'">LCV</Checkbox>
                                            <Checkbox label="02" v-bind:disabled="this.carTypeSwitch2 == '2'">中卡</Checkbox>
                                            <Checkbox label="03" v-bind:disabled="this.carTypeSwitch3 == '3'">重卡</Checkbox>
                                        </Checkbox-group>
                                    </FormItem>
                                </Col>

                                <Col span="12">
                                    <FormItem label="城市经理" prop="customerManagerOld" v-if="!basicTypeForm.id">
                                        <Select v-model="basicTypeForm.customerManagerOld" placeholder="城市经理" class="w200">
                                            <Option v-for="(item,index) in salesManDataOld" :value="item.username" :label="item.userRealName" :key="index" >
                                            </Option>
                                        </Select>
                                    </FormItem>
                                </Col>

                            </Row>

                            <Row>
                                <Col span="12">
                                    <FormItem label="评级" prop="channelGradeOld" >
                                        <Select v-model="basicTypeForm.channelGradeOld" placeholder="评级" class="w200">
                                            <Option value="1">A</Option>
                                            <Option value="2">B</Option>
                                            <Option value="3">C</Option>
                                            <Option value="4">D</Option>
                                        </Select>
                                    </FormItem>
                                </Col>

                                <Col span="12">
                                    <FormItem label="保证金(元)" prop="channelDepositOld">
                                        <Input v-model.trim="basicTypeForm.channelDepositOld" class="w200"  placeholder="请输入"/>
                                    </FormItem>
                                </Col>
                            </Row>

                            <Row>
                                <!-- 签放额度判断 -->
                                <Col span="12">
                                    <FormItem label="是否控制额度" prop="isLimitPutOld">
                                        <RadioGroup v-model="basicTypeForm.isLimitPutOld" @on-change="checkLimitPut()">
                                            <Radio label="1">是</Radio>
                                            <Radio label="0">否</Radio>
                                        </RadioGroup>
                                    </FormItem>
                                </Col>

                                <!-- 先放后抵额度判断 -->
                                <Col span="12">
                                    <FormItem label="是否控制额度" prop="isLimitPledgeOld" >
                                        <RadioGroup v-model="basicTypeForm.isLimitPledgeOld" @on-change="checkLimitPut()">
                                            <Radio label="1">是</Radio>
                                            <Radio label="0">否</Radio>
                                        </RadioGroup>
                                    </FormItem>
                                </Col>
                            </Row>

                            <Row>
                                <Col span="12">
                                    <FormItem label="签放额度(元)" prop="limitPutOld" :rules="Number(basicTypeForm.isLimitPutOld)?limitPutOld:notLimitPutOld">
                                        <Input v-model.trim="basicTypeForm.limitPutOld" class="w200"  placeholder="请输入"/>
                                    </FormItem>
                                </Col>

                                <Col span="12">
                                    <FormItem label="先放后抵额度(元)" prop="limitPledgeOld" :rules="Number(basicTypeForm.isLimitPledgeOld)?limitPledgeOld:notLimitPledgeOld">
                                        <Input v-model.trim="basicTypeForm.limitPledgeOld" class="w200"  placeholder="请输入"/>
                                    </FormItem>
                                </Col>
                            </Row>

                            <Row>
                                <!-- 签放额度 -->
                                <Col span="12">
                                    <FormItem label="临时额度(元)" prop="temporaryLimitPutOld" >
                                        <Input v-model.trim="basicTypeForm.temporaryLimitPutOld" class="w200"  placeholder="请输入" @on-change="checkdate()"/>
                                    </FormItem>
                                </Col>

                                <!-- 先放后抵额度 -->
                                <Col span="12">
                                    <FormItem label="临时额度(元)" prop="temporaryLimitPledgeOld"  >
                                        <Input v-model.trim="basicTypeForm.temporaryLimitPledgeOld" class="w200"  placeholder="请输入" @on-change="checkdate()"/>
                                    </FormItem>
                                </Col>
                            </Row>

                            <Row>
                                <!-- 签放额度有效期 -->
                                <Col span="12">
                                    <Form-item label="有效期" prop="limitPutTimeOld" :rules="Number(oldCarDate1) != 1?notNewCarLimitPutTime:newCarLimitPutTime" >
                                        <Date-picker type="date" v-model="basicTypeForm.limitPutTimeOld" class="w200"  placeholder="选择日期" ></Date-picker>
                                    </Form-item>
                                </Col>

                                <!-- 先放后抵额度有效期 -->
                                <Col span="12">
                                    <Form-item label="有效期" prop="limitPledgeTimeOld" :rules="Number(oldCarDate2) != 1?notNewCarLimitPutTime:newCarLimitPutTime">
                                        <Date-picker type="date" v-model="basicTypeForm.limitPledgeTimeOld" class="w200"  placeholder="选择日期" ></Date-picker>
                                    </Form-item>
                                </Col>
                            </Row>

                            <Row>
                                <!-- 签放额度占用 -->
                                <Col span="12">
                                    <FormItem label="占用额度(元)" prop="limitPutTakeOld">
                                        <Input v-model.trim="basicTypeForm.limitPutTakeOld" class="w200"  readonly="readonly"   placeholder="系统自动计算"/>
                                    </FormItem>
                                </Col>

                                <!-- 先放后抵额度占用 -->
                                <Col span="12">
                                    <FormItem label="占用额度(元)" prop="limitPledgeTakeOld">
                                        <Input v-model.trim="basicTypeForm.limitPledgeTakeOld" class="w200"  readonly="readonly"  placeholder="系统自动计算"/>
                                    </FormItem>
                                </Col>

                            </Row>

                            <Row>
                                <!-- 剩余签放额度 -->
                                <Col span="12">
                                    <FormItem label="剩余额度(元)" prop="limitPutResidueOld">
                                        <Input v-model.trim="basicTypeForm.limitPutResidueOld" class="w200"  readonly="readonly"   placeholder="系统自动计算"/>
                                    </FormItem>
                                </Col>

                                <!-- 剩余先放后抵额度 -->
                                <Col span="12">
                                    <FormItem label="剩余额度(元)" prop="limitPledgeResidueOld">
                                        <Input v-model.trim="basicTypeForm.limitPledgeResidueOld" class="w200"   readonly="readonly"  placeholder="系统自动计算"/>
                                    </FormItem>
                                </Col>
                            </Row>
                        </div>

                        <div class="common_br">
                            <h2 class="common_channel_title" >二手车授权区域/授权车型</h2>
                            <div class="common_content" style="padding-left: 16%;">
                                <Row>
                                    <Row>
                                        <Col span="12">
                                            <FormItem label="区域是否生效" prop="authRegionSwitchOld">
                                                <RadioGroup v-model="basicTypeForm.authRegionSwitchOld" >
                                                    <Radio label="1">是</Radio>
                                                    <Radio label="0">否</Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </Col>

                                        <Col span="12">
                                            <FormItem label="车型是否生效" prop="authVehicleTypeSwitchOld">
                                                <RadioGroup v-model="basicTypeForm.authVehicleTypeSwitchOld" >
                                                    <Radio label="1">是</Radio>
                                                    <Radio label="0">否</Radio>
                                                </RadioGroup>
                                            </FormItem>
                                        </Col>
                                    </Row>

                                    <Row>
                                        <Col span="12" style="height:200px;overflow-y:auto">
                                            <FormItem label="" prop="mainAreaOld">
                                                <Tree :data="areasDataOld" ref="treeOld" show-checkbox v-model="basicTypeForm.mainAreaOld" > </Tree>
                                            </FormItem>
                                        </Col>

                                        <Col span="12" style="height:200px;overflow-y:auto">
                                            <FormItem label="" prop="mainCarOld">
                                                <Tree :data="carsDataOld" ref="carstreeOld" show-checkbox v-model="basicTypeForm.mainCarOld" > </Tree>
                                            </FormItem>
                                        </Col>
                                    </Row>
                                </Row>
                                <div>
                                    <a class="select-clear" @click="showAreasOldCar">选择渠道展业区域查看</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    </Card>
                </div>

            </Form>
        </div>
        <Modal :title="modalTitle" v-model="blackApplyVisible" :mask-closable='false' :width="500" :styles="{top: '100px'}">
            <Form ref="blackApplyForm" :model="blackApplyForm" :label-width="70" :rules="blackApplyFormValidate">
                <FormItem label="申请原因" prop="blacklistReason">
                    <Input v-model.trim="blackApplyForm.blacklistReason" class="w400"  placeholder="请输入黑名单申请原因" type="textarea" :rows="6"/>
                </FormItem>
            </Form>
            <div slot="footer" style="text-align:center;" >
                <Button type="text" @click="cancel">取消</Button>
                <Button type="primary" @click="join">提交</Button>
            </div>
        </Modal>

        <Modal :title="areaTitle" v-model="areaVisible" :mask-closable='false' :width="1000" :styles="{top: '300px'}">
            <Row>
                <Table :loading="loading" border :columns="columns" :data="dataArea" sortable="custom"
                       @on-sort-change="changeSort" @on-selection-change="showSelect" ref="table">
                </Table>
            </Row>
            <Row type="flex" justify="end" class="page">
                <Page :current="searchForm.pageNumber" :total="totalArea" :page-size="searchForm.pageSize"
                      @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]"
                      size="small" show-total show-elevator show-sizer></Page>
            </Row>
        </Modal>
        <MapModal :mapModal="mapModal" :mapLocation="mapLocation" :mapAddress="mapAddress" @confirmLngLat="confirmLngLat" @closeMapModel="closeMapModel" />
    </div>
</template>

<script>
    import MapModal from '_p/afs-apply/pages/common/map/MapModal';
    import vueEvent from "_p/afs-apply/assets/js/vueEvent.js"
    import PlaceCascade from "@/components/place-cascade";
    import {
        getBrandTree,
        //保存直营车商
        addChannel,
        //暂存
        stagingSaveDirectCarDealer,
        //更新直营车商
        updateChannel,
        //获取直营车商展业区域
        getDirectCardealerAreaListData,
        //根据车商id获取收款账户信息
        getAccountInfoByChannelId,

        getAllSaleManByChannelId,

        checkCooper,
        getChannelBaseInfo,
        //获取渠道风控信息
        getChannelRiskInfoById,
        //获取渠道保证金信息
        getChannelQuotaInfoById,
        //查询授权区域信息
        getMainAreaById,
        //查询主营品牌信息
        getCarBrandById,
        //授权车型
        getVehicleById,
        //省市树
        getAllAddressList,
        //  获取当前合作商授权区域
        getAreaByChannelId,

        getNewVehicleById,
        getOldVehicleById,
    } from "@/projects/afs-apply/api/car-dealer/dealer";

    import {
        getDictDataByType
    } from "_p/basic/api/admin/datadic.js";

    import {getLocation} from "_p/afs-apply/api/apply-report/personal/common";

    import {
        saveBlack,
        checkBlack,
    } from "@/projects/afs-apply/api/affiliation/affiliationAddEdit";

    import {getChannelId } from "@/projects/afs-apply/api/register-mng/listRecord";
    import {formatDate} from "_c/iview/components/date-picker/util";
    import {deepClone} from "@/libs/utils/ObjectClone";

    export default {
        name:"direct_cardealer_basic_info",
        data() {
            let validate = function(rule, value, callback){
                console.log(value,"qweqweqweqweq")
                if(!value){
                    return callback("日期不能为空");
                }
                if(Array.isArray(value)){//格式为：daterange、datetimerange检测
                    value.map(function(item){
                        if(item === '' ||item == undefined){
                            return callback("日期不能为空")
                        }
                    })
                }else{ //格式为：date、datetime、year、month 检测
                    if(value === ''){
                        return callback("日期不能为空")
                    }
                }
                return callback()
            };
            let notValidate = function (rule, value, callback) {
                if (Array.isArray(value)) {//格式为：daterange、datetimerange检测
                    value.map(function (item) {
                        if (item === "") {
                            //return callback("日期不能为空")
                        }
                    })
                } else { //格式为：date、datetime、year、month 检测
                    if (value === '') {
                        //return callback("日期不能为空")
                    }
                }
                return callback()
            };
            const validatePassword  = (rule, code, callback) => {
                var city = {
                    11: "北京",
                    12: "天津",
                    13: "河北",
                    14: "山西",
                    15: "内蒙古",
                    21: "辽宁",
                    22: "吉林",
                    23: "黑龙江 ",
                    31: "上海",
                    32: "江苏",
                    33: "浙江",
                    34: "安徽",
                    35: "福建",
                    36: "江西",
                    37: "山东",
                    41: "河南",
                    42: "湖北 ",
                    43: "湖南",
                    44: "广东",
                    45: "广西",
                    46: "海南",
                    50: "重庆",
                    51: "四川",
                    52: "贵州",
                    53: "云南",
                    54: "西藏 ",
                    61: "陕西",
                    62: "甘肃",
                    63: "青海",
                    64: "宁夏",
                    65: "新疆",
                    71: "台湾",
                    81: "香港",
                    82: "澳门",
                    91: "国外 "
                };
                var tip = ""
                var pass = true

                if (!code || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)) {
                    tip = "身份证号格式错误"
                    pass = false;
                } else if (!city[code.substr(0, 2)]) {
                    tip = "身份证号格式错误"
                    pass = false
                } else {
                    // 18位身份证需要验证最后一位校验位
                    if (code.length === 18) {
                        code = code.split('')
                        // ∑(ai×Wi)(mod 11)
                        // 加权因子
                        var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
                        // 校验位
                        var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2]
                        var sum = 0
                        var ai = 0
                        var wi = 0
                        for (var i = 0; i < 17; i++) {
                            ai = code[i]
                            wi = factor[i]
                            sum += ai * wi
                        }
                        var last = parity[sum % 11];
                        if (parity[sum % 11] != code[17]) {
                            tip = "身份证号格式错误"
                            pass = false
                        }
                    }
                }
                if (!pass) {
                    callback(new Error(tip))
                } else {
                    callback()
                }
                // if (!pass) alert(tip)
                // return pass
            };


            const validateMobile = (rule, value, callback) => {
                var reg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
                if (!reg.test(value)) {
                    callback(new Error("手机号格式错误"));
                } else {
                    callback();
                }
            };
            const validateAmount = (rule, value, callback) => {
                var reg = /^\d+(\.\d+)?$/;
                if (!reg.test(value) && value != "") {
                    callback(new Error("数值类型格式错误"));
                }else{
                    callback();
                }
            };
            const validatesocUniCrtCode = (rule, value, callback) => {
                var reg = /^([0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}|[1-9]\d{14})$/;
                if (!reg.test(value)) {
                    callback(new Error("统一社会信用码格式错误"));
                } else {
                    callback();
                }
            };
            return{

                //在黑名单
                inBlackList: true,

                //有效期表单验证
                newCarDate1:"",
                newCarDate2:"",
                oldCarDate1:"",
                oldCarDate2:"",

                mapModal: false, // 地图弹窗
                mapLocation:'', // 地图定位
                mapAddress:'', // 详细地址
                canOpenMapModal: false, // 是否可以打开地图弹窗


                showGroupNewCar:"",
                showGroupOldCar:"",
                showOldCar:"",
                showNewCar:"",
                //是否禁用新车按钮：默认否
                viewNewCar:"0",
                //是否禁用二手车按钮：默认否
                viewOldCar:"0",
                isNewCarRole:"",
                isOldCarRole:"",
                //控制是否更新
                updateswitch:false,
                //控制经纬度范围是否显示
                showRangeSwitch:false,
                //默认是非管理员账号,后面也要改
                isEmployee:false,
                associAccount:"",
               // typeId:"",
                //汇款对象可以选择开关
                accountSwitch:"1",

                //车商状态默认为草稿
                channelStatus:"02",
                //二手车状态
                channelStatusOldCar:"",
                channelStatusNewCar:"",

                loading:false,
                submitLoading: false,
                disabledPaymentObject:"0",
                readOnly:false,
                isShowModel:false,
                expandLevel: 0,
                carLevel: 0,
                //黑名单
                modalTitle: "",
                //展业区域
                areaTitle:"",
                //黑明单申请弹窗
                blackApplyVisible: false,
                //展业区域弹窗
                areaVisible:false,
                typeCode:1,
                typeCode2:0,
                mainCar:[],
                mainArea:[],
                //渠道归属数据字典
                channelBelongList:[],
                //汇款对象
                paymentObjectList:[],
                location:[],
                gpsvendorauthor: [
                    {
                        value: '1',
                        label: 'GPS厂商1'
                    },
                    {
                        value: '2',
                        label: 'GPS厂商2'
                    },
                    {
                        value: '3',
                        label: 'GPS厂商3'
                    },
                ],

                // 运营公司
                companyList:[
                    {
                        value:"00",
                        label:"内部车型库",
                    },
                    {
                        value:"01",
                        label:"外部车型库",
                    },
                    {
                        value:"02",
                        label:"厂商认定",
                    },
                    {
                        value:"02",
                        label:"第三方评估",
                    }
                ],
                searchForm: {
                    pageNumber: 1,
                    pageSize: 10,
                    areaId:[],
                    businessType:"",
                },
                columns: [
                    {
                        type: 'index',
                        title:"序号",
                        minWidth: 80,
                        align: "center",
                        fixed: "left"

                    },
                    {
                        title: "直营车商名称",
                        key: "channelFullName",
                        minWidth: 120,
                    },
                    {
                        title: "地区",
                        key: "areaTitle",
                        minWidth: 145
                    },
                ],
                dataArea: [],
                totalArea: 0,
                //所有渠道信息
                channelData:[],

                //旧的状态
                OldStatus:"",
                newCar:true,
                oldCar:true,
                //开票信息
                invoiceForm:{
                    id:"",
                    taxpayerType:"",
                    taxpayerIdNumber:"",
                    invoiceTelNumber:"",
                    invoiceAddress:"",
                    openingBank:"",
                    bankAccount:"",
                    channelStatus:"",
                    taxRate:"",
                },

                //合作商下所有业务员集合
                salesManData:[],
                salesManDataOld:[],

                //gps厂商字典
                gpsvendorauthorList: [],
                //GPS安装方式字典
                gpsinstalmodeList: [],

                //优质等级字典处理
                qualityGradeList:[],
                saleMan:"",
                saleManOld:"",
                businessTypeSwitch0:"-1",
                businessTypeSwitch1:"-1",
                businessTypeSwitch2:"-1",
                businessTypeSwitch3:"-1",

                carTypeSwitch0:"-1",
                carTypeSwitch1:"-1",
                carTypeSwitch2:"-1",
                carTypeSwitch3:"-1",

                basicTypeForm:{


                    channelName:"",
                    oldChannelId:"",
                    channelId:"",
                    id:"",
                    //车商类型 4s 汽贸
                    cardealType:"",
                    //账户信息
                    accountInfo:"1",
                    mainBrand:[],
                    channelAddressDetail:"",

                    //admin地址省市区
                    channelAdminAddressValue:[],
                    //注册地址省市区
                    channelAddressValue:[],
                    //办公地址省市区
                    officeAddressValue:[],
                    pageNumber: 1,
                    pageSize: 10,
                    //渠道名称
                    channelFullName:"",
                    //上线日期
                    onlineDate:"",
                    //统一社会信用代码
                    socUniCrtCode:"",
                    //法人
                    legalPerson:"",
                    //法人身份证号
                    legalPersonIdCard:"",
                    //法人电话
                    legalPersonTel:"",
                    //实际控制人
                    actualController:"",
                    //实际控制人电话
                    actualControllerTel:"",
                    //实际控制人身份证号
                    actualControllerIdCard:"",
                    //管理员姓名
                    channelAdmin:"",
                    //管理员电话
                    channelAdminTel:"",
                    //管理员证件号码
                    channelAdminIdCard:"",
                    //管理员邮箱
                    channelAdminMail:"",
                    //地址经纬度
                    longitude:"",
                    latitude:"",
                    //经纬度范围（km）
                    longitudeLatitudeRange:"",
                    //公司人数
                    companiesNumber:1,
                    //经营场所面积
                    businessArea:"",
                    //汇款对象
                    paymentObject:"",
                    //注册日期
                    registrationDate:"",
                    //注册资金(万元)
                    registeredCapital:"",
                    //实收资本(万元)
                    subscribedCapital:"",
                    //业务类型
                    businessType:[],
                    //资产净值
                    netAssetValue:"",
                    //经营年限
                    businessLife:"",
                    //GPS厂商授权
                    gpsVendorAuthor:[],
                    //资产负债率
                    assetLiabilityRatio:"",
                    //上一年度经营利润
                    operatingProfit:"",
                    //GPS安装方式
                    gpsInstalMode:"",
                    //业绩
                    achievement:"",
                    //利润率增长率
                    proGrowthRate:"",
                    //销售收入增长率
                    saleIncreaseRate:"",
                    //流动比例
                    currentRatio:"",
                    //优质等级
                    qualityGrade:"",
                    //二手车优质等级
                    qualityGradeOld:"",
                    //有效期
                    validDate:[],
                    //二手车有效期
                    validDateOld:[],
                    //车辆类型
                    carType:[],
                    //二手车车辆类型
                    carTypeOld:[],
                    //区域经理
                    customerManager:"",
                    //二手车区域经理
                    customerManagerOld:"",
                    //二手车账号最大数量
                    accountMaxNumOld:"",
                    //新车账号最大数量
                    accountMaxNum:"",
                    //层级最大数量
                    hierarchy:1,
                    //评级
                    channelGrade:"",
                    //二手车评级
                    channelGradeOld:"",
                    //保证金
                    channelDeposit:"",
                    //二手车保证金
                    channelDepositOld:"",
                    //是否控制额度
                    isLimitPut:"",
                    //二手车是否控制额度
                    isLimitPutOld:"",
                    //是否控制额度
                    isLimitPledge:"",
                    //二手车是否控制额度
                    isLimitPledgeOld:"",
                    //签放额度
                    limitPut:"",
                    //签放额度
                    limitPutOld:"",
                    //先放后抵额度
                    limitPledge:"",
                    //二手车先放后抵额度
                    limitPledgeOld:"",
                    //签放额度临时额度
                    temporaryLimitPut:"",
                    //二手车签放额度临时额度
                    temporaryLimitPutOld:"",
                    //先放后抵额度临时额度
                    temporaryLimitPledge:"",
                    //二手车先放后抵额度临时额度
                    temporaryLimitPledgeOld:"",
                    //签放额度有效期
                    limitPutTime:"",
                    //二手车签放额度有效期
                    limitPutTimeOld:"",
                    //先放后抵额度有效期
                    limitPledgeTime:"",
                    //二手车先放后抵额度有效期
                    limitPledgeTimeOld:"",
                    //签放额度占用
                    limitPutTake:"",
                    //二手车签放额度占用
                    limitPutTakeOld:"",
                    //先放后抵额度占用
                    limitPledgeTake:"",
                    //二手车先放后抵额度占用
                    limitPledgeTakeOld:"",
                    //剩余签放额度
                    limitPutResidue:"",
                    //二手车剩余签放额度
                    limitPutResidueOld:"",
                    //剩余先放后抵额度
                    limitPledgeResidue:"",
                    //二手车剩余先放后抵额度
                    limitPledgeResidueOld:"",
                    //区域是否生效
                    authRegionSwitch:"",
                    //二手车区域是否生效
                    authRegionSwitchOld:"",
                    //车型是否生效
                    authVehicleTypeSwitch:"",
                    //二手车是否生效
                    authVehicleTypeSwitchOld:"",
                    //经纬度是否控制
                    longitudeLatitudeSwitch:"",
                    //业务人员关联车商
                    personRelCardealerSwitch:"",
                    //进件选择车商
                    choiceCardealerSwitch:"",
                },
                basicTypeFormValidate:{
                    channelId: [
                        { required: true, message: "合作商名称不能为空", trigger: "change"}
                    ],

                    channelFullName: [
                        { required: true, message: "车商名称不能为空", trigger: "blur"}
                    ],
                    onlineDate: [
                        { required: true, validator: validate, trigger: "change"}
                    ],
                    /*onlineDate: [
                        { required: true, message: "上线日期不能为空", trigger: "blur",type:"date"}
                    ],*/
                    socUniCrtCode: [
                        { required: true, message: "统一社会信用代码不能为空", trigger: "blur"},
                        {validator: validatesocUniCrtCode, trigger: "blur"}
                    ],
                    legalPerson:[
                        { required: true, message: "法人不能为空", trigger: "blur"}
                    ],
                    legalPersonIdCard:[
                        { required: true, message: "法人身份证号不能为空", trigger: "blur"},
                        { validator: validatePassword, trigger: "blur" }
                    ],
                    legalPersonTel:[
                        { required: true, message: "法人电话不能为空", trigger: "blur"},
                        {validator: validateMobile, trigger: "blur"}
                    ],
                    actualController:[
                        { required: true, message: "实际控制人不能为空", trigger: "blur"}
                    ],
                    actualControllerTel:[
                        { required: true, message: "实际控制人电话不能为空", trigger: "blur"},
                        {validator: validateMobile, trigger: "blur"}
                    ],
                    actualControllerIdCard:[
                        { required: true, message: "实际控制人身份证号不能为空", trigger: "blur"},
                        { validator: validatePassword, trigger: "blur" }
                    ],

                    longitude:[
                        { required: true, message: "地址经度不能为空", trigger: "change"}
                    ],
                    latitude:[
                        { required: true, message: "地址纬度不能为空", trigger: "change"}
                    ],
                    companiesNumber:[
                        { required: true,type: 'number',message: "公司人数", trigger: "blur"}
                    ],
                    accountMaxNum:[
                        { required: true,type: 'number',message: "账号最大数量", trigger: "blur"}
                    ],
                    hierarchy:[
                        { required: true,type: 'number',message: "层级最大数量", trigger: "blur"}
                    ],
                    longitudeLatitudeRange:[
                        { required: true, message: "经纬度范围不能为空", trigger: "blur"}
                    ],
                    businessArea:[
                        { required: true, message: "经营场所面积不能为空", trigger: "blur"}
                    ],
                    paymentObject:[
                        { required: true, message: "汇款对象不能为空", trigger: "change"}
                    ],
                    registrationDate:[
                        { required: true, validator: validate, trigger: "change"}
                    ],
                    registeredCapital:[
                        { required: true, message: "注册资金不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],

                    channelAddressValue:[
                        { required: true, message: "注册地址不能为空", trigger: "blur",type:"array"}
                    ],
                    channelAddressDetail:[
                        { required: true, message: "详细地址不能为空", trigger: "blur"}
                    ],
                    /*subscribedCapital:[
                        { required: true, message: "实收资本不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],*/
                    businessType: [
                        { required: true, type: 'array', min: 1, message: '业务类型不能为空', trigger: 'blur' },
                    ],
                    /*netAssetValue:[
                        { required: true, message: "资产净值不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],*/
                    businessLife:[
                        { required: true, message: "经营年限不能为空", trigger: "blur"}
                    ],
                    gpsVendorAuthor:[
                        { required: true, type: 'array', min: 1, message: 'GPS厂商授权不能为空', trigger: 'change' },
                    ],
                    /*assetLiabilityRatio:[
                        { required: true ,message: "资产负债率不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],*/
                    /*operatingProfit:[
                        { required: true, message: "上一年度经营利润不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],*/
                    gpsInstalMode:[
                        { required: true,  message: 'GPS安装方式不能为空', trigger: 'blur' },
                    ],
                    /*achievement:[
                        { required: true, message: "业绩不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],*/
                    /*proGrowthRate:[
                        { required: true, message: "利润率增长率不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],*/
                    /*saleIncreaseRate:[
                        { required: true, message: "销售收入增长率不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],
                    currentRatio:[
                        { required: true, message: "流动比例不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],*/
                   /* qualityGrade:[
                        { required: true, message: "优质等级不能为空", trigger: "change"}
                    ],
                    qualityGradeOld:[
                        { required: true, message: "优质等级不能为空", trigger: "change"}
                    ],*/
                    /*validDate:[
                        { required: true, validator: validate, trigger: "change"}
                    ],
                    validDateOld:[
                        { required: true, validator: validate, trigger: "change"}
                    ],*/
                    carType:[
                        { required: true, type: 'array', message: '车辆类型不能为空', trigger: 'change' },
                    ],
                    carTypeOld:[
                        { required: true, type: 'array', message: '车辆类型不能为空', trigger: 'change' },
                    ],
                    customerManager:[
                        { required: true, message: "城市经理不能为空", trigger: "change"}
                    ],
                    customerManagerOld:[
                        { required: true, message: "城市经理不能为空", trigger: "change"}
                    ],
                    channelGrade:[
                        { required: true, message: "评级不能为空", trigger: "change"}
                    ],
                    channelGradeOld:[
                        { required: true, message: "评级不能为空", trigger: "change"}
                    ],
                    /*channelDeposit:[
                        { required: true, message: "保证金不能为空", trigger: "blur" },
                        {validator: validateAmount, trigger: "blur"}
                    ],
                    channelDepositOld:[
                        { required: true, message: "保证金不能为空", trigger: "blur" },
                        {validator: validateAmount, trigger: "blur"}
                    ],*/
                    isLimitPut:[
                        { required: true, message: "是否控制额度不能为空", trigger: "change"}
                    ],
                    isLimitPutOld:[
                        { required: true, message: "是否控制额度不能为空", trigger: "change"}
                    ],
                    isLimitPledge:[
                        { required: true, message: "是否控制额度不能为空", trigger: "change"}
                    ],
                    isLimitPledgeOld:[
                        { required: true, message: "是否控制额度不能为空", trigger: "change"}
                    ],

                    temporaryLimitPut:[
                        {validator: validateAmount, trigger: "blur"}
                    ],
                    temporaryLimitPutOld:[
                        {validator: validateAmount, trigger: "blur"}
                    ],
                    temporaryLimitPledge:[
                        {validator: validateAmount, trigger: "blur"}
                    ],
                    temporaryLimitPledgeOld:[
                        {validator: validateAmount, trigger: "blur"}
                    ],
                    /*temporaryLimitPut:[
                        { required: true, message: "临时额度不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],
                    temporaryLimitPledge:[
                        { required: true, message: "临时额度不能为空", trigger: "blur"},
                        {validator: validateAmount, trigger: "blur"}
                    ],*/
                    limitPutTime:[
                    ],
                    limitPledgeTime:[
                      //  { required: true, validator: validate, trigger: "change"}
                    ],

                    limitPutTimeOld:[
                      //  { required: true, validator: validate, trigger: "change"}
                    ],
                    limitPledgeTimeOld:[
                       // { required: true, validator: validate, trigger: "change"}
                    ],

                    authRegionSwitch:[
                        { required: true, message: "区域是否生效不能为空", trigger: "change"}
                    ],
                    authRegionSwitchOld:[
                        { required: true, message: "区域是否生效不能为空", trigger: "change"}
                    ],
                    authVehicleTypeSwitch:[
                        { required: true, message: "车型是否生效不能为空", trigger: "change"}
                    ],
                    authVehicleTypeSwitchOld:[
                        { required: true, message: "车型是否生效不能为空", trigger: "change"}
                    ],
                    longitudeLatitudeSwitch:[
                        { required: true, message: "经纬度是否控制不能为空", trigger: "change"}
                    ],
                    accountInfo:[
                        { required: true, message: "账户信息不能为空", trigger: "change"}
                    ],
                    cardealType:[
                        { required: true, message: "车商类型不能为空", trigger: "change"}
                    ],
                    personRelCardealerSwitch:[
                        { required: true, message: "业务人员关联车不能为空", trigger: "change"}
                    ],
                    choiceCardealerSwitch:[
                        { required: true, message: "进件选择车商不能为空", trigger: "change"}
                    ],
                },
                limitPut:[
                    { required: true, message: "签放额度不能为空", trigger: "blur"},
                    {validator: validateAmount, trigger: "blur"}
                ],
                notLimitPut:[
                    {validator: validateAmount, trigger: "blur"},
                    //{validator: validateAmount, trigger: "blur"}
                ],
                limitPutOld:[
                    { required: true, message: "签放额度不能为空", trigger: "blur"},
                    {validator: validateAmount, trigger: "blur"}
                ],
                notLimitPutOld:[
                    {validator: validateAmount, trigger: "blur"}
                ],
                limitPledge:[
                    { required: true, message: "先放后抵额度不能为空", trigger: "blur"},
                    {validator: validateAmount, trigger: "blur"}
                ],
                notLimitPledge:[
                    {validator: validateAmount, trigger: "blur"}
                ],
                limitPledgeOld:[
                    { required: true, message: "先放后抵额度不能为空", trigger: "blur"},
                    {validator: validateAmount, trigger: "blur"}
                ],
                notLimitPledgeOld:[
                    {validator: validateAmount, trigger: "blur"}
                ],

                validDate:[
                    { required: true, validator: validate, trigger: "change"}
                ],
                notValidDate:[
                    { required: false, validator: notValidate, trigger: "change"}
                ],
                validDateOld:[
                    { required: true, validator: validate, trigger: "change"}
                ],
                notValidDateOld:[
                    { required: false, validator: notValidate, trigger: "change"}
                ],
                notNewCarLimitPutTime:[
                    { required: false, validator: notValidate, trigger: "change"}
                ],
                newCarLimitPutTime:[
                    { required: true, validator: notValidate, trigger: "change"}
                ],

                //黑名单
                blackApplyForm:{
                    blacklistReason:"",

                },
                //黑名单
                blackApplyFormValidate:{
                },
                baseData: [],
                areasData:[],
                carsData: [],
                carsDataOld:[],
                areasDataOld:[],
                showGroupNewCar:"0",//默认隐藏新车
                showGroupOldCar:"0",//默认隐藏二手车
                showOldCar:"0",//默认隐藏二手车
                showNewCar:"0",//默认隐藏二手车
            }
        },
        components:{
            PlaceCascade,
            MapModal,
        },
        props:{
            channelType:{
                type:String,
            }
        },
        watch:{
           /* channelType:function(val){
                if(this.basicTypeForm.channelBelong ==null || this.basicTypeForm.channelBelong =="" || this.basicTypeForm.channelBelong ==undefined){
                    this.basicTypeForm.channelBelong=this.channelType
                    if(this.basicTypeForm.channelBelong=="00"){
                        //如果古道归属为sp：则汇款对象只能为主体
                        this.basicTypeForm.paymentObject="0";
                        this.disabledPaymentObject="1";
                    }
                }
            },*/

        },
        methods:{
            init() {
                ////this.getAllChannelInfo();
                this.initDataDic();
                this.getLocationData();
                this.getChannelId();

                this.getProvinceData();
                this.getCityData();

            },
            getChannelId(){
                getChannelId({}).then(res => {
                    if (res.code === "0000") {
                        this.basicTypeForm.channelId = res.data;
                        getChannelBaseInfo(this.basicTypeForm.channelId).then(res => {
                            if (res.code === "0000") {
                                this.basicTypeForm.channelName = res.data[0].channelFullName;
                                this.getChannelInfoById();
                            }
                        });

                        //根据渠道id查询授权区域
                        this.getAreaByChannelId(this.basicTypeForm.channelId,"01");
                        this.getAreaByChannelId(this.basicTypeForm.channelId,"02");
                    }
                })
            },

            //根据渠道id获取授权区域
            getAreaByChannelId(v,b){
                getAreaByChannelId(v,b).then(res => {
                    if (res.code === "0000") {
                        // 仅展开指定级数 默认一级
                        let expandLevel = this.expandLevel;
                        res.data.forEach(function (e) {
                            if (expandLevel == "0") {
                                if (e.addrLevel === "0") {
                                    e.expand = true;
                                }
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (c.addrLevel === "1") {
                                            c.expand = false;
                                        }
                                    });
                                }
                            } else {
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (expandLevel == 1) {
                                            if (c.addrLevel === "1") {
                                                c.expand = false;
                                            }
                                        }
                                    });
                                }
                            }
                        });
                        if(b=="01"){
                            this.areasData= deepClone(res.data);
                        }else if(b=="02"){
                            this.areasDataOld =deepClone(res.data);
                        }
                    }
                })

                setTimeout(() => {
                    let id = this.basicTypeForm.id;
                    if(id!=null && id!="" && id!= undefined){
                        //根据渠道id查询授权区域
                        getMainAreaById(id).then(resMainArea => {
                            this.loading = false;
                            if (resMainArea.code === "0000") {
                                let areas = resMainArea.data;
                                areas.forEach((item, i) => {
                                    if(item.businessType=="01"){
                                        //新车
                                        this.checkAreaTree(this.areasData, areas,"01");
                                    }else{
                                        //二手车
                                        this.checkAreaTree(this.areasDataOld, areas,"02");
                                    }
                                })
                            }
                        })
                    }
                },600);
            },


            getChannelInfo(v) {
                //根据id查询直营车商基本信息
                this.loading = true;
                getChannelBaseInfo(v).then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        this.basicTypeForm.id=res.data[0].id;
                        this.basicTypeForm.channelCode=res.data[0].channelCode;
                        this.basicTypeForm.channelFullName=res.data[0].channelFullName;
                        this.basicTypeForm.onlineDate=res.data[0].onlineDate;
                        this.basicTypeForm.socUniCrtCode=res.data[0].socUniCrtCode;
                        this.basicTypeForm.legalPerson=res.data[0].legalPerson;
                        this.basicTypeForm.legalPersonIdCard=res.data[0].legalPersonIdCard;
                        this.basicTypeForm.legalPersonTel=res.data[0].legalPersonTel;
                        this.basicTypeForm.cardealType=res.data[0].carDealType;
                        this.basicTypeForm.accountInfo=res.data[0].accountInfo;
                        this.basicTypeForm.actualController=res.data[0].actualController;
                        this.basicTypeForm.actualControllerTel=res.data[0].actualControllerTel;
                        this.basicTypeForm.actualControllerIdCard=res.data[0].actualControllerIdCard;
                        this.basicTypeForm.channelAdmin=res.data[0].channelAdmin;
                        this.basicTypeForm.channelAdminTel=res.data[0].channelAdminTel;
                        this.basicTypeForm.channelAdminMail=res.data[0].channelAdminMail;
                        this.basicTypeForm.longitude=res.data[0].longitude;
                        this.basicTypeForm.latitude=res.data[0].latitude;
                        this.basicTypeForm.longitudeLatitudeRange=res.data[0].longitudeLatitudeRange;
                        this.basicTypeForm.businessArea=res.data[0].businessArea;
                        this.basicTypeForm.paymentObject=res.data[0].paymentObject;
                        this.basicTypeForm.registrationDate=res.data[0].registrationDate;
                        this.basicTypeForm.channelBelong=res.data[0].channelBelong;
                        this.basicTypeForm.hierarchy=res.data[0].hierarchy;
                        this.basicTypeForm.channelAdminIdCard =res.data[0].channelAdminIdCard;
                        this.basicTypeForm.companiesNumber =res.data[0].companiesNumber;
                        this.OldStatus =res.data[0].channelStatus;


                        if(res.data[0].registeredCapital || res.data[0].registeredCapital== 0 ){
                            this.basicTypeForm.registeredCapital=res.data[0].registeredCapital+"";
                        }
                        if(res.data[0].assetLiabilityRatio || res.data[0].assetLiabilityRatio==0){
                            this.basicTypeForm.assetLiabilityRatio=res.data[0].assetLiabilityRatio+"";
                        }
                        if(res.data[0].businessLife || res.data[0].businessLife==0){
                            this.basicTypeForm.businessLife=res.data[0].businessLife+"";
                        }
                        if(res.data[0].operatingProfit||res.data[0].operatingProfit==0){
                            this.basicTypeForm.operatingProfit=res.data[0].operatingProfit+"";
                        }
                        if(res.data[0].achievement||res.data[0].achievement==0){
                            this.basicTypeForm.achievement=res.data[0].achievement+"";
                        }
                        if(res.data[0].subscribedCapital||res.data[0].subscribedCapital==0){
                            this.basicTypeForm.subscribedCapital=res.data[0].subscribedCapital+"";
                        }
                        if(res.data[0].netAssetValue||res.data[0].netAssetValue==0){
                            this.basicTypeForm.netAssetValue=res.data[0].netAssetValue+"";
                        }
                        if(res.data[0].proGrowthRate||res.data[0].proGrowthRate==0){
                            this.basicTypeForm.proGrowthRate=res.data[0].proGrowthRate+"";
                        }
                        if(res.data[0].saleIncreaseRate||res.data[0].saleIncreaseRate==0){
                            this.basicTypeForm.saleIncreaseRate=res.data[0].saleIncreaseRate+"";
                        }
                        if(res.data[0].currentRatio||res.data[0].currentRatio==0){
                            this.basicTypeForm.currentRatio=res.data[0].currentRatio+"";
                        }
                        this.basicTypeForm.longitudeLatitudeSwitch=res.data[0].longitudeLatitudeSwitch;
                        this.basicTypeForm.personRelCardealerSwitch=res.data[0].personRelCardealerSwitch;
                        this.basicTypeForm.choiceCardealerSwitch=res.data[0].choiceCardealerSwitch;
                        this.basicTypeForm.businessType=res.data[0].businessType.split(',');
                        this.basicTypeForm.gpsVendorAuthor=res.data[0].gpsVendorAuthor.split(',');
                        this.basicTypeForm.gpsInstalMode=res.data[0].gpsInstalMode;

                        let channelAddressValue = [];
                        channelAddressValue[0]=res.data[0].channelProvince;
                        channelAddressValue[1]=res.data[0].channelCity;
                        this.basicTypeForm.channelAddressValue=channelAddressValue;
                        this.basicTypeForm.channelAddressDetail=res.data[0].channelAddress;

                        //开票信息
                        this.invoiceForm.taxpayerType=res.data[0].taxpayerType;
                        this.invoiceForm.taxpayerIdNumber=res.data[0].taxpayerIdNumber;
                        this.invoiceForm.invoiceTelNumber=res.data[0].invoiceTelNumber;
                        this.invoiceForm.invoiceAddress=res.data[0].invoiceAddress;
                        this.invoiceForm.openingBank=res.data[0].openingBank;
                        this.invoiceForm.bankAccount=res.data[0].bankAccount;
                        this.invoiceForm.taxRate=res.data[0].taxRate;

                        this.getChannelInfoById(-1);

                        setTimeout(() => {
                            this.getDetailAddress1(res.data[0].channelProvince,res.data[0].channelCity);
                            this.checkdate();
                        },1000)

                    }
                });
                //根据渠道id查询风控信息
                getChannelRiskInfoById(v).then(resRisk => {
                    this.loading = false;
                    if (resRisk.code === "0000") {
                        let str = JSON.stringify(resRisk.data);
                        let channelRiskInfoTemp = JSON.parse(str);
                        channelRiskInfoTemp.forEach((item, i) => {
                            //新车
                            if(item.businessType=="01"){
                                let validDate = [];
                                validDate[0]=item.qualityStartDate;
                                validDate[1]=item.qualityEndDate;
                                this.basicTypeForm.validDate=validDate;
                                this.basicTypeForm.carType=item.carType.split(',');
                                this.basicTypeForm.qualityGrade =item.qualityGrade;
                                this.basicTypeForm.customerManager=item.customerManager;

                                //this.saleMan =item.customerManager;
                                this.basicTypeForm.channelGrade =item.channelGrade;
                                if(item.channelDeposit || item.channelDeposit=="0"){
                                    this.basicTypeForm.channelDeposit =item.channelDeposit+"";
                                }
                                this.basicTypeForm.authRegionSwitch =item.authRegionSwitch;
                                this.basicTypeForm.authVehicleTypeSwitch =item.authVehicleTypeSwitch;
                                this.basicTypeForm.accountMaxNum = item.accountMaxNum;
                                this.checkAllNewCar(v);
                            }else{
                                //二手车
                                let validDate = [];
                                validDate[0]=item.qualityStartDate;
                                validDate[1]=item.qualityEndDate;
                                this.basicTypeForm.validDateOld=validDate;
                                this.basicTypeForm.carTypeOld=item.carType.split(',');
                                this.basicTypeForm.qualityGradeOld =item.qualityGrade;
                                this.basicTypeForm.customerManagerOld=item.customerManager;
                                this.basicTypeForm.channelGradeOld =item.channelGrade;
                                if(item.channelDeposit || item.channelDeposit=="0"){
                                    this.basicTypeForm.channelDepositOld =item.channelDeposit+"";
                                }
                                this.basicTypeForm.authRegionSwitchOld =item.authRegionSwitch;
                                this.basicTypeForm.authVehicleTypeSwitchOld =item.authVehicleTypeSwitch;
                                this.basicTypeForm.accountMaxNumOld = item.accountMaxNum;
                                //编辑或回显数据时候根据车辆类型重新获取对应车型
                                this.checkAllOldCar(v);
                            }
                        })
                        /*if(this.basicTypeForm.qualityGrade !=null && this.basicTypeForm.qualityGrade !="" && this.basicTypeForm.qualityGrade != undefined){
                            if(this.basicTypeForm.qualityGradeOld !=null && this.basicTypeForm.qualityGradeOld !="" && this.basicTypeForm.qualityGradeOld != undefined){
                                this.basicTypeForm.businessType=["0","1"];
                            }else{
                                this.basicTypeForm.businessType=["0"];
                            }
                        }else{
                            this.basicTypeForm.businessType=["1"];
                        }*/
                        this.carBusinessType();
                       /* this.basicTypeForm.customerManagerOld = this.saleManOld;
                        this.basicTypeForm.customerManager = this.saleMan;*/



                    }
                });

                //根据渠道id查询保证金信息
                getChannelQuotaInfoById(v).then(resQuota => {
                    this.loading = false;
                    if (resQuota.code === "0000") {

                        let str = JSON.stringify(resQuota.data);
                        let ChannelQuotaInfoTemp = JSON.parse(str);
                        ChannelQuotaInfoTemp.forEach((item, i) => {
                            //新车
                            if(item.businessType=="01"){
                                //签放额度
                                if (item.quotaType == "1") {
                                    if(item.quotaControlSwitch){
                                        this.basicTypeForm.isLimitPut = item.quotaControlSwitch+"";
                                    }
                                    if(item.quotaAmount || item.quotaAmount=="0"){
                                        this.basicTypeForm.limitPut = item.quotaAmount+"";
                                    }
                                    if(item.tempQuota || item.tempQuota=="0"){
                                        this.basicTypeForm.temporaryLimitPut=item.tempQuota+"";
                                    }
                                    if(item.occupiedQuota || item.occupiedQuota=="0"){
                                        this.basicTypeForm.limitPutTake=item.occupiedQuota+"";
                                    }
                                    this.basicTypeForm.limitPutTime=item.validityTermEnd;
                                    if(item.surplusQuota || item.surplusQuota=="0"){
                                        this.basicTypeForm.limitPutResidue=item.surplusQuota+"";
                                    }
                                } else {
                                    //先放后抵
                                    if(item.quotaControlSwitch){
                                        this.basicTypeForm.isLimitPledge = item.quotaControlSwitch+"";
                                    }
                                    if(item.quotaAmount || item.quotaAmount=="0"){
                                        this.basicTypeForm.limitPledge = item.quotaAmount+"";

                                    }
                                    if(item.tempQuota || item.tempQuota=="0"){
                                        this.basicTypeForm.temporaryLimitPledge=item.tempQuota+"";
                                    }
                                    if(item.occupiedQuota || item.occupiedQuota=="0"){
                                        this.basicTypeForm.limitPledgeTake=item.occupiedQuota+"";
                                    }
                                    this.basicTypeForm.limitPledgeTime=item.validityTermEnd;
                                    if(item.surplusQuota || item.surplusQuota=="0"){
                                        this.basicTypeForm.limitPledgeResidue=item.surplusQuota+"";
                                    }
                                }
                            }else{
                                //二手车
                                //签放额度
                                if (item.quotaType == "1") {
                                    if(item.quotaControlSwitch){
                                        this.basicTypeForm.isLimitPutOld = item.quotaControlSwitch+"";
                                    }
                                    if(item.quotaAmount || item.quotaAmount=="0"){
                                        this.basicTypeForm.limitPutOld = item.quotaAmount+"";
                                    }
                                    if(item.tempQuota || item.tempQuota=="0"){
                                        this.basicTypeForm.temporaryLimitPutOld=item.tempQuota+"";
                                    }
                                    if(item.occupiedQuota || item.occupiedQuota=="0"){
                                        this.basicTypeForm.limitPutTakeOld=item.occupiedQuota+"";
                                    }
                                    this.basicTypeForm.limitPutTimeOld=item.validityTermEnd;
                                    if(item.surplusQuota || item.surplusQuota=="0"){
                                        this.basicTypeForm.limitPutResidueOld=item.surplusQuota+"";
                                    }
                                } else {
                                    //先抵后放
                                    if(item.quotaControlSwitch){
                                        this.basicTypeForm.isLimitPledgeOld = item.quotaControlSwitch+"";
                                    }
                                    if(item.quotaAmount || item.quotaAmount=="0"){
                                        this.basicTypeForm.limitPledgeOld = item.quotaAmount+"";

                                    }
                                    if(item.tempQuota || item.tempQuota=="0"){
                                        this.basicTypeForm.temporaryLimitPledgeOld=item.tempQuota+"";
                                    }
                                    if(item.occupiedQuota || item.occupiedQuota=="0"){
                                        this.basicTypeForm.limitPledgeTakeOld=item.occupiedQuota+"";
                                    }
                                    this.basicTypeForm.limitPledgeTimeOld=item.validityTermEnd;
                                    if(item.surplusQuota || item.surplusQuota=="0"){
                                        this.basicTypeForm.limitPledgeResidueOld=item.surplusQuota+"";
                                    }
                                }
                            }

                        })
                    }
                })
            },
            getChannelList(v) {
                // 多件基本信息
                this.loading = true;
                getChannelListData(this.basicTypeForm).then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        this.data = res.data.records;
                        this.total = res.data.total;
                    }
                });
            },
            //地址公共信息调用
            locationChange(item, callback) {
                item.loading = true;
                getLocation({upperCode: item.value}).then(res => {
                    if (res.code === "0000") {
                        res.data.forEach(function (item) {
                            if (item.isParent) {
                                item.loading = false;
                                item.children = [];
                            }
                        });
                        item.children = res.data;
                        item.loading = false;
                        callback();
                    }
                })
            },

            getLocationData() {
                let param = ""
                param = {
                    level: '1',
                    upperCode: '1'
                };
                getLocation(param).then((res) => {
                    if (res.code == "0000") {
                        res.data.forEach(item => {
                            // 表明是否是父节点
                            if (item.isParent) {
                                item.loading = false;
                                item.children = [];
                            }
                        })
                    }
                    this.location.push(...res.data);
                })
            },

            closeModel(value){
                this.isShowModel=value;
            },
            //Gps授权厂商
            handgps_vendor_author (val) {
                this.gpsvendorauthor.push({
                    value: val,
                    label: val
                });
            },
            //GPS安装方式
            handgps_instal_mode(val) {
                this.gpsinstalmode.push({
                    value: val,
                    label: val
                });
            },

            showAreasNewCar(){
                //新车展业区域查看
                let areaId = [];
                let selectedAreaNodes = this.$refs.tree.getSelectedNodes();
                selectedAreaNodes.forEach(function (e) {
                    areaId.push(e.id);
                });
                if(areaId.length==0){
                    this.$Message.error("请至少选中一个区域!");
                    return;
                }
                this.areaVisible=true;
                this.searchForm.areaId=areaId;
                this.searchForm.businessType="01";
                this.getAreaList();
            },
            showAreasOldCar(){
                //二手车展业区域
                let areaId = [];
                let selectedAreaNodes = this.$refs.treeOld.getSelectedNodes();
                selectedAreaNodes.forEach(function (e) {
                    areaId.push(e.id);
                });
                if(areaId.length==0){
                    this.$Message.error("请至少选中一个区域!");
                    return;
                }
                this.areaVisible=true;
                this.searchForm.areaId=areaId;
                this.searchForm.businessType="02";
                this.getAreaList();
            },
            /*//新车区域展示
            addNewCar(){
                this.showNewCar="1";
                this.showOldCar="0";
            },
            //二手车展示
            addOldCar(){
                this.showNewCar="0";
                this.showOldCar="1";
            },*/
            selectDateRange(v) {
                if (v) {
                    this.basicTypeForm.startDate = v[0];
                    this.basicTypeForm.endDate = v[1];
                }
            },
            getAreaList() {
                // 多条件搜索已上线的直营车商展业区域
                this.loading = true;
                getDirectCardealerAreaListData(this.searchForm).then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        this.dataArea = res.data.records;
                        this.totalArea = res.data.total;
                    }
                });
            },
            refresh() {
                this.$refs['basicTypeForm'].reloadData();
            },


            //直营车商车商保存为草稿
            basicSave(){
                console.log("渠道基本信息保存开始！");
                //有效期表单验证
                //this.verifyLimitDate();
                this.channelStatus="02"
                this.channelStatusNewCar="";
                this.channelStatusOldCar="";
                this.$refs.basicTypeForm.validate(valid => {
                    console.log(valid);
                    if (valid) {

                        this.$parent.spinShow=true;
                        let brandIds = [];
                        try {
                            let selectedBrandNodes = this.$refs.baseTree.getCheckedAndIndeterminateNodes();
                            selectedBrandNodes.forEach(function (e) {
                                let index = selectedBrandNodes.findIndex(m => m.indeterminate==false && m.code === e.upperCode)
                                if(index < 0) {
                                    if(e.indeterminate==undefined){
                                        e.indeterminate=" ";
                                    }
                                    if(e.spellCode==undefined){
                                        e.spellCode=" ";
                                    }
                                    brandIds.push(e.code+","+e.title+","+e.indeterminate+","+e.carLevel+","+e.spellCode);
                                    if(e.carLevel=="0" && e.indeterminate==false){
                                        throw Error();
                                    }
                                }
                            });
                        }catch (e) {
                        }

                        this.basicTypeForm.mainBrand=brandIds;

                        let areaIds = [];
                        let carIds = [];
                        //新车角色权限 && 而且当前页面存在新车表单
                        if(this.isNewCarRole=="1"){
                            let selectedAreaNodes = this.$refs.tree.getCheckedAndIndeterminateNodes();
                            selectedAreaNodes.forEach(function (e) {
                                let isParent="";
                                if(e.isParent==true){
                                    //是否为父节点
                                    isParent="1"
                                }else{
                                    isParent="0"
                                }
                                areaIds.push(e.value+","+e.title+","+isParent+","+e.upperCode);
                            });
                            if(areaIds.length===0 && this.basicTypeForm.authRegionSwitch=="1"){
                                this.$Message.error("请勾选新车授权区域");
                                this.$parent.loadingSave=false;
                                this.$parent.spinShow=false;
                                return false;
                            }

                            try {
                                let selectedCarIdsNodes = this.$refs.carstree.getCheckedAndIndeterminateNodes();
                                selectedCarIdsNodes.forEach(function (e) {
                                    let index = selectedCarIdsNodes.findIndex(m => m.indeterminate==false && m.code === e.upperCode)
                                    if(index < 0) {
                                        if(e.indeterminate==undefined){
                                            e.indeterminate=" ";
                                        }
                                        if(e.spellCode==undefined){
                                            e.spellCode=" ";
                                        }
                                        carIds.push(e.code+","+e.title+","+e.upperCode+","+e.indeterminate+","+e.carLevel+","+e.spellCode+","+e.carType);
                                        if(e.carLevel=="0" && e.indeterminate==false){
                                            throw Error();
                                        }
                                    }
                                });
                            }catch (e) {
                            }
                            if(carIds.length===0 && this.basicTypeForm.authVehicleTypeSwitch=="1"){
                                this.$Message.error("请勾新车授权车型");
                                this.$parent.loadingSave=false;
                                this.$parent.spinShow=false;
                                return false;
                            }
                            this.channelStatusNewCar=this.channelStatus;
                        }
                        this.basicTypeForm.mainArea=areaIds;
                        this.basicTypeForm.mainCar=carIds;

                        let carOldIds = [];
                        let areaOldIds = [];
                        //二手车角色权限 && 而且当前页面存在二手车表单
                        if(this.isOldCarRole=="1"){
                            try {
                                let selectedCarOLdIdsNodes = this.$refs.carstreeOld.getCheckedAndIndeterminateNodes();
                                selectedCarOLdIdsNodes.forEach(function (e) {
                                    let index = selectedCarOLdIdsNodes.findIndex(m => m.indeterminate==false && m.code === e.upperCode)
                                    if(index < 0) {
                                        if(e.indeterminate==undefined){
                                            e.indeterminate=" ";
                                        }
                                        if(e.spellCode==undefined){
                                            e.spellCode=" ";
                                        }
                                        carOldIds.push(e.code+","+e.title+","+e.upperCode+","+e.indeterminate+","+e.carLevel+","+e.spellCode+","+e.carType);
                                        if(e.carLevel=="0" && e.indeterminate==false){
                                            throw Error();
                                        }
                                    }
                                });
                            }catch (e) {
                            }
                            if(carOldIds.length==0 && this.basicTypeForm.authVehicleTypeSwitchOld=="1"){
                                this.$Message.error("请勾二手车授权车型");
                                this.$parent.loadingSave=false;
                                this.$parent.spinShow=false;
                                return false;
                            }
                            let selectedAreaOldNodes = this.$refs.treeOld.getCheckedAndIndeterminateNodes();
                            selectedAreaOldNodes.forEach(function (e) {
                                let isParent="";
                                if(e.isParent==true){
                                    //是否为父节点
                                    isParent="1"
                                }else{
                                    isParent="0"
                                }
                                areaOldIds.push(e.value+","+e.title+","+isParent+","+e.upperCode);
                            });
                            if(areaOldIds.length==0 && this.basicTypeForm.authRegionSwitchOld=="1"){
                                this.$Message.error("请勾选二手车授权区域");
                                this.$parent.loadingSave=false;
                                this.$parent.spinShow=false;
                                return false;
                            }
                            this.channelStatusOldCar=this.channelStatus;
                        }
                        this.basicTypeForm.mainCarOld=carOldIds;
                        this.basicTypeForm.mainAreaOld=areaOldIds;

                        console.log("渠道基本信息");
                        if(this.basicTypeForm.channelId==undefined){
                            this.basicTypeForm.channelId=="";
                        }
                        //上线日期
                        if(this.basicTypeForm.onlineDate != null || this.basicTypeForm.onlineDate !=""){
                            this.basicTypeForm.onlineDate =formatDate(this.basicTypeForm.onlineDate,"yyyy-MM-dd")
                        }
                        //新车有效期
                        if(this.basicTypeForm.validDate != null || this.basicTypeForm.validDate !=""){
                            this.basicTypeForm.validDate[0] =formatDate(this.basicTypeForm.validDate[0],"yyyy-MM-dd")
                            this.basicTypeForm.validDate[1] =formatDate(this.basicTypeForm.validDate[1],"yyyy-MM-dd")
                        }
                        //二手车有效期
                        if(this.basicTypeForm.validDateOld != null || this.basicTypeForm.validDateOld !=""){
                            this.basicTypeForm.validDateOld[0] =formatDate(this.basicTypeForm.validDateOld[0],"yyyy-MM-dd")
                            this.basicTypeForm.validDateOld[1] =formatDate(this.basicTypeForm.validDateOld[1],"yyyy-MM-dd")
                        }
                        //注册日期
                        if(this.basicTypeForm.registrationDate != null || this.basicTypeForm.registrationDate !=""){
                            this.basicTypeForm.registrationDate =formatDate(this.basicTypeForm.registrationDate,"yyyy-MM-dd")
                        }
                        //新车先放有效期
                        if(this.basicTypeForm.limitPutTime != null || this.basicTypeForm.limitPutTime !=""){
                            this.basicTypeForm.limitPutTime =formatDate(this.basicTypeForm.limitPutTime,"yyyy-MM-dd")
                        }
                        //新车后放有效期
                        if(this.basicTypeForm.limitPledgeTime != null || this.basicTypeForm.limitPledgeTime !=""){
                            this.basicTypeForm.limitPledgeTime =formatDate(this.basicTypeForm.limitPledgeTime,"yyyy-MM-dd")
                        }
                        //二手车先放有效期
                        if(this.basicTypeForm.limitPutTimeOld != null || this.basicTypeForm.limitPutTimeOld !=""){
                            this.basicTypeForm.limitPutTimeOld =formatDate(this.basicTypeForm.limitPutTimeOld,"yyyy-MM-dd")
                        }
                        //二手车后放有效期
                        if(this.basicTypeForm.limitPledgeTimeOld != null || this.basicTypeForm.limitPledgeTimeOld !=""){
                            this.basicTypeForm.limitPledgeTimeOld =formatDate(this.basicTypeForm.limitPledgeTimeOld,"yyyy-MM-dd")
                        }


                        let param = {
                            //当前登陆者是否拥用新车角色权限:0否，1是(暂时测试给1、后续调整根据账户体系自动判断取值)
                            isNewCarRole:this.isNewCarRole,
                            //当前登陆者是否拥用二手车角色权限:0否，1是(暂时测试给1、后续调整根据账户体系自动判断取值)
                            isOldCarRole:this.isOldCarRole,

                            oldChannelId:this.basicTypeForm.oldChannelId,
                            channelCoopeCardealerTemp: {
                                channelId: this.basicTypeForm.channelId,
                                associAccount: this.basicTypeForm.customerManager,
                                associAccountOld: this.basicTypeForm.customerManagerOld,
                                cardealerType: "02",
                                status: this.channelStatus,
                            },
                            //渠道基本信息f
                            channelBaseInfoTemp: {
                                //渠道类型：直营车商
                                channelType:"02",
                                //主键
                                id:this.basicTypeForm.id,
                                //渠道代码
                                channelCode: this.basicTypeForm.channelCode,
                                //合作商全称
                                channelFullName:this.basicTypeForm.channelFullName.replace(/\s*/g,""),
                                //上线日期
                                onlineDate:this.basicTypeForm.onlineDate,
                                //统一社会信用代码
                                socUniCrtCode:this.basicTypeForm.socUniCrtCode.replace(/\s*/g,""),
                                //法人
                                legalPerson:this.basicTypeForm.legalPerson.replace(/\s*/g,""),
                                //法人身份证号
                                legalPersonIdCard:this.basicTypeForm.legalPersonIdCard,
                                //法人电话
                                legalPersonTel:this.basicTypeForm.legalPersonTel,
                                //实际控制人
                                actualController:this.basicTypeForm.actualController.replace(/\s*/g,""),
                                //实际控制人身份证号
                                actualControllerIdCard:this.basicTypeForm.actualControllerIdCard,
                                //实际控制人电话
                                actualControllerTel:this.basicTypeForm.actualControllerTel,
                                //管理员姓名
                                channelAdmin:this.basicTypeForm.channelAdmin.replace(/\s*/g,""),
                                //管理员电话
                                channelAdminTel:this.basicTypeForm.channelAdminTel,
                                //管理员邮箱
                                channelAdminMail:this.basicTypeForm.channelAdminMail,
                                //管理员证件号码
                                channelAdminIdCard:this.basicTypeForm.channelAdminIdCard,
                                //渠道管理员详细地址
                                channelAdminAddress:this.basicTypeForm.channelAdminAddressDetail,
                                //注册地址详细地址
                                channelAddress:this.basicTypeForm.channelAddressDetail,
                                //办公地址详细地址
                                officeAddress:this.basicTypeForm.officeAddressDetail,
                                //地址经纬度
                                longitude:this.basicTypeForm.longitude,
                                latitude:this.basicTypeForm.latitude,
                                //经纬度范围
                                longitudeLatitudeRange:this.basicTypeForm.longitudeLatitudeRange.replace(/\s*/g,""),
                                //公司人数
                                companiesNumber:this.basicTypeForm.companiesNumber,
                                //车商性质
                                carDealType:this.basicTypeForm.cardealType,
                                //经营场所面积
                                businessArea:this.basicTypeForm.businessArea,
                                //汇款对象
                                paymentObject:this.basicTypeForm.paymentObject,
                                //注册日期
                                registrationDate:this.basicTypeForm.registrationDate,
                                //主营品牌
                                mainBrand:this.basicTypeForm.mainBrand,
                                //注册资金
                                registeredCapital:this.basicTypeForm.registeredCapital,
                                //实收资本
                                subscribedCapital:this.basicTypeForm.subscribedCapital,
                                //渠道归属
                                channelBelong:this.basicTypeForm.channelBelong,
                                //业务类型;新车/二手车
                                delete:this.basicTypeForm.businessType,
                                businessType:this.basicTypeForm.businessType.join(','),

                                //资产净值
                                netAssetValue:this.basicTypeForm.netAssetValue,
                                //经营年限
                                businessLife:this.basicTypeForm.businessLife,
                                //GPS厂商授权
                                delete:this.basicTypeForm.gpsVendorAuthor,
                                gpsVendorAuthor:this.basicTypeForm.gpsVendorAuthor.join(','),

                                //资产负债率
                                assetLiabilityRatio:this.basicTypeForm.assetLiabilityRatio,
                                //上一年度经营利润
                                operatingProfit:this.basicTypeForm.operatingProfit,
                                //GPS安装方式
                                //delete:this.basicTypeForm.gpsInstalMode,
                                gpsInstalMode:this.basicTypeForm.gpsInstalMode,

                                //业绩
                                achievement:this.basicTypeForm.achievement,
                                //利润率增长率
                                proGrowthRate:this.basicTypeForm.proGrowthRate,
                                //销售收入增长率
                                saleIncreaseRate:this.basicTypeForm.saleIncreaseRate,
                                //流动比率
                                currentRatio:this.basicTypeForm.currentRatio,
                                //资产负债率
                                assetLiabilityRatio:this.basicTypeForm.assetLiabilityRatio,
                                //车辆类型;新车;二手车
                                //delete:this.basicTypeForm.carType,
                                //carType:this.basicTypeForm.carType.join(','),
                                //经纬度是否控制;是/否
                                longitudeLatitudeSwitch:this.basicTypeForm.longitudeLatitudeSwitch,
                                //业务人员关联车商;是/否
                                personRelCardealerSwitch:this.basicTypeForm.personRelCardealerSwitch,
                                //进件选择车商;是/否
                                choiceCardealerSwitch:this.basicTypeForm.choiceCardealerSwitch,
                                //层级最大数目
                                hierarchy:this.basicTypeForm.hierarchy,

                                channelStatus:this.channelStatusNewCar,
                                channelStatusOldCar:this.channelStatusOldCar,
                                accountInfo:this.basicTypeForm.accountInfo,

                            },
                            //管理员省市区
                            // channelAdminAddressValue:this.basicTypeForm.channelAdminAddressValue,
                            //注册地省市区
                            channelAddressValue:this.basicTypeForm.channelAddressValue,
                            //办公室省市区
                            //   officeAddressValue:this.basicTypeForm.officeAddressValue,
                            //新车授权区域
                            mainArea:this.basicTypeForm.mainArea,
                            //新车主营品牌
                            mainBrand:this.basicTypeForm.mainBrand,
                            //新车授权车型
                            mainCar:this.basicTypeForm.mainCar,

                            //新车授权区域
                            mainAreaOld:this.basicTypeForm.mainAreaOld,
                            //二手车授权车型
                            mainCarOld:this.basicTypeForm.mainCarOld,

                            //新车渠道风控信息
                            channelRiskInfoTemp: {
                                //业务类型：新车
                                businessType:"01",
                                qualityGrade:this.basicTypeForm.qualityGrade,
                                qualityStartDate:this.basicTypeForm.validDate[0],
                                qualityEndDate:this.basicTypeForm.validDate[1],

                                delete:this.basicTypeForm.carType,
                                carType:this.basicTypeForm.carType.join(','),
                                authRegionSwitch:this.basicTypeForm.authRegionSwitch,
                                authVehicleTypeSwitch:this.basicTypeForm.authVehicleTypeSwitch,
                                channelGrade:this.basicTypeForm.channelGrade,
                                channelDeposit:this.basicTypeForm.channelDeposit,
                                customerManager:this.basicTypeForm.customerManager,
                                accountMaxNum:this.basicTypeForm.accountMaxNum,
                            },
                            //二手车渠道风控信息
                            channelRiskInfoTempOld: {
                                //业务类型：二手车
                                businessType:"02",
                                qualityGrade:this.basicTypeForm.qualityGradeOld,
                                qualityStartDate:this.basicTypeForm.validDateOld[0],
                                qualityEndDate:this.basicTypeForm.validDateOld[1],

                                delete:this.basicTypeForm.carTypeOld,
                                carType:this.basicTypeForm.carTypeOld.join(','),
                                authRegionSwitch:this.basicTypeForm.authRegionSwitchOld,
                                authVehicleTypeSwitch:this.basicTypeForm.authVehicleTypeSwitchOld,
                                channelGrade:this.basicTypeForm.channelGradeOld,
                                channelDeposit:this.basicTypeForm.channelDepositOld,
                                customerManager:this.basicTypeForm.customerManagerOld,
                                accountMaxNum:this.basicTypeForm.accountMaxNumOld,
                            },
                            //新车渠道保证金信息
                            channelQuotaInfoTempList: [
                                //签放额度
                                {
                                    //额度类型：签放额度
                                    quotaType:"1",
                                    //业务类型:新车
                                    businessType:"01",
                                    //是否控制额度
                                    quotaControlSwitch:this.basicTypeForm.isLimitPut,
                                    //额度金额
                                    quotaAmount:this.basicTypeForm.limitPut,
                                    //临时额度
                                    tempQuota:this.basicTypeForm.temporaryLimitPut,
                                    //有效期
                                    validityTermEnd:this.basicTypeForm.limitPutTime,
                                    //占用额度
                                    occupiedQuota:this.basicTypeForm.limitPutTake,
                                    //剩余额度
                                    surplusQuota:this.basicTypeForm.limitPutResidue,

                                },
                                //先放后抵押额度
                                {
                                    //额度类型：先放后抵押额度
                                    quotaType:"2",
                                    //业务类型
                                    businessType:"01",
                                    //是否控制额度
                                    quotaControlSwitch:this.basicTypeForm.isLimitPledge,
                                    //额度金额
                                    quotaAmount:this.basicTypeForm.limitPledge,
                                    //临时额度
                                    tempQuota:this.basicTypeForm.temporaryLimitPledge,
                                    //有效期
                                    validityTermEnd:this.basicTypeForm.limitPledgeTime,
                                    //占用额度
                                    occupiedQuota:this.basicTypeForm.limitPledgeTake,
                                    //剩余额度
                                    surplusQuota:this.basicTypeForm.limitPledgeResidue,
                                }
                            ],

                            //二手车保证金信息
                            channelQuotaInfoTempOldList: [
                                //签放额度
                                {
                                    //额度类型：签放额度
                                    quotaType:"1",
                                    //业务类型:新车
                                    businessType:"02",
                                    //是否控制额度
                                    quotaControlSwitch:this.basicTypeForm.isLimitPutOld,
                                    //额度金额
                                    quotaAmount:this.basicTypeForm.limitPutOld,
                                    //临时额度
                                    tempQuota:this.basicTypeForm.temporaryLimitPutOld,
                                    //有效期
                                    validityTermEnd:this.basicTypeForm.limitPutTimeOld,
                                    //占用额度
                                    occupiedQuota:this.basicTypeForm.limitPutTakeOld,
                                    //剩余额度
                                    surplusQuota:this.basicTypeForm.limitPutResidueOld,

                                },
                                //先放后抵押额度
                                {
                                    //额度类型：先放后抵押额度
                                    quotaType:"2",
                                    //业务类型
                                    businessType:"02",
                                    //是否控制额度
                                    quotaControlSwitch:this.basicTypeForm.isLimitPledgeOld,
                                    //额度金额
                                    quotaAmount:this.basicTypeForm.limitPledgeOld,
                                    //临时额度
                                    tempQuota:this.basicTypeForm.temporaryLimitPledgeOld,
                                    //有效期
                                    validityTermEnd:this.basicTypeForm.limitPledgeTimeOld,
                                    //占用额度
                                    occupiedQuota:this.basicTypeForm.limitPledgeTakeOld,
                                    //剩余额度
                                    surplusQuota:this.basicTypeForm.limitPledgeResidueOld,
                                }
                            ],
                        }

                        //黑名单保存验证改渠道是否在黑名单信息表中
                        let blackParams={
                            //黑名单类型：直营车商
                            blacklistType:'05',
                            //黑名单名称
                            blackName:this.basicTypeForm.channelFullName,
                            //证件类型：统一社会信息代码
                            idType:'02',
                            //统一社会信用代码
                            idCode:this.basicTypeForm.socUniCrtCode,
                        }
                        checkBlack(blackParams).then(res => {
                            if (res.code === "0000") {
                                //黑名单判断字段:是
                                if(res.weatherBlackList === "1"){
                                    this.$Message.error("该车商已存在黑名单信息库中！");
                                    this.$parent.spinShow=false;
                                }else {
                                    if(this.basicTypeForm.id !=null && this.basicTypeForm.id !="" && this.basicTypeForm.id != undefined && this.OldStatus !="06"){
                                        updateChannel(param).then(res => {
                                            if (res.code === "0000") {
                                                this.$Message.success("保存成功");

                                                this.basicTypeForm.id=res.data[0].id;
                                                this.basicTypeForm.oldChannelId=res.data[1].channelId;

                                                //账户页面信息更新
                                                this.$parent.getAccountInfo(this.basicTypeForm.id);
                                                //回显业务员
                                                this.getAllSaleManByChannelId();
                                                //基本信息处理
                                                this.getChannelInfo(res.data[0].id);
                                                this.$parent.setchannelId(res.data[0].id);
                                                // this.getMainAreaList(res.data[0].id);
                                                this.getChannelId();
                                                this.getBaseTreeList(res.data[0].id);
                                                //this.getCarsTreeList(res.data[0].id);
                                                this.$parent.spinShow=false;

                                            }
                                        }).catch(() => {
                                            this.$parent.spinShow=false;
                                        });
                                    }else {
                                        addChannel(param).then(res => {
                                            if (res.code === "0000") {
                                                this.$Message.success("保存成功");

                                                //基本信息处理
                                                this.basicTypeForm.id=res.data[0].id;
                                                this.basicTypeForm.oldChannelId=res.data[1].channelId;
                                                //账户页面信息更新
                                                this.$parent.getAccountInfo(this.basicTypeForm.id);
                                                //回显业务员
                                                this.getAllSaleManByChannelId();

                                                this.getChannelInfo(res.data[0].id);
                                                this.$parent.setchannelId(res.data[0].id);
                                                //this.getMainAreaList(res.data[0].id);
                                                this.getChannelId();
                                                this.getBaseTreeList(res.data[0].id);
                                                //this.getCarsTreeList(res.data[0].id);
                                                this.$parent.spinShow=false;
                                            }
                                        }).catch(() => {
                                            this.$parent.spinShow=false;
                                        });
                                    }

                                }
                            }
                        }).catch(() => {
                            this.$Message.error("未知错误,请联系管理员！");
                            this.$parent.spinShow=false;
                        });

                    }else{
                        this.$Message.error('请补全基本信息');
                        for (let i in this.$refs.basicTypeForm.fields) {
                            if (this.$refs.basicTypeForm.fields[i].validateState === "error") {
                                this.$refs.basicTypeForm.fields[i].$el.scrollIntoView({
                                    block: "center",
                                    behavior: "smooth",
                                    inline: "center"
                                });
                                break;
                            }
                        }
                        this.$parent.spinShow=false;
                    }
                });
            },

            //暂存
            stagingSave(){
                console.log("渠道基本信息暂存开始！");

                if(this.basicTypeForm.socUniCrtCode==null || this.basicTypeForm.socUniCrtCode=="" || this.basicTypeForm.socUniCrtCode==undefined){
                    this.$Message.error("请先输入统一社会信用代码!");
                    return false;
                }else{
                    var reg = /^([0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}|[1-9]\d{14})$/;
                    if (!reg.test(this.basicTypeForm.socUniCrtCode)) {
                        return false;
                    }
                }


                this.$parent.spinShow=true;
                this.channelStatusOldCar='02';
                let brandIds = [];
                try {
                    let selectedBrandNodes = this.$refs.baseTree.getCheckedAndIndeterminateNodes();
                    selectedBrandNodes.forEach(function (e) {
                        let index = selectedBrandNodes.findIndex(m => m.indeterminate==false && m.code === e.upperCode)
                        if(index < 0) {
                            if(e.indeterminate==undefined){
                                e.indeterminate=" ";
                            }
                            if(e.spellCode==undefined){
                                e.spellCode=" ";
                            }
                            brandIds.push(e.code+","+e.title+","+e.indeterminate+","+e.carLevel+","+e.spellCode);
                            if(e.carLevel=="0" && e.indeterminate==false){
                                throw Error();
                            }
                        }
                    });
                }catch (e) {
                }

                this.basicTypeForm.mainBrand=brandIds;

                let areaIds = [];
                let carIds = [];
                //新车角色权限 && 而且当前页面存在新车表单
                if(this.isNewCarRole=="1"){
                    let selectedAreaNodes = this.$refs.tree.getCheckedAndIndeterminateNodes();
                    selectedAreaNodes.forEach(function (e) {
                        let isParent="";
                        if(e.isParent==true){
                            //是否为父节点
                            isParent="1"
                        }else{
                            isParent="0"
                        }
                        areaIds.push(e.value+","+e.title+","+isParent+","+e.upperCode);
                    });


                    try {
                        let selectedCarIdsNodes = this.$refs.carstree.getCheckedAndIndeterminateNodes();
                        selectedCarIdsNodes.forEach(function (e) {
                            let index = selectedCarIdsNodes.findIndex(m => m.indeterminate==false && m.code === e.upperCode)
                            if(index < 0) {
                                if(e.indeterminate==undefined){
                                    e.indeterminate=" ";
                                }
                                if(e.spellCode==undefined){
                                    e.spellCode=" ";
                                }
                                carIds.push(e.code+","+e.title+","+e.upperCode+","+e.indeterminate+","+e.carLevel+","+e.spellCode+","+e.carType);
                                if(e.carLevel=="0" && e.indeterminate==false){
                                    throw Error();
                                }
                            }
                        });
                    }catch (e) {
                    }

                    this.channelStatusNewCar='02';
                }
                this.basicTypeForm.mainArea=areaIds;
                this.basicTypeForm.mainCar=carIds;

                let carOldIds = [];
                let areaOldIds = [];
                //二手车角色权限 && 而且当前页面存在二手车表单
                if(this.isOldCarRole=="1"){
                     try {
                        let selectedCarOLdIdsNodes = this.$refs.carstreeOld.getCheckedAndIndeterminateNodes();
                        selectedCarOLdIdsNodes.forEach(function (e) {
                            let index = selectedCarOLdIdsNodes.findIndex(m => m.indeterminate==false && m.code === e.upperCode)
                            if(index < 0) {
                                if(e.indeterminate==undefined){
                                    e.indeterminate=" ";
                                }
                                if(e.spellCode==undefined){
                                    e.spellCode=" ";
                                }
                                carOldIds.push(e.code+","+e.title+","+e.upperCode+","+e.indeterminate+","+e.carLevel+","+e.spellCode+","+e.carType);
                                if(e.carLevel=="0" && e.indeterminate==false){
                                    throw Error();
                                }
                            }
                        });
                    }catch (e) {
                    }

                    let selectedAreaOldNodes = this.$refs.treeOld.getCheckedAndIndeterminateNodes();
                    selectedAreaOldNodes.forEach(function (e) {
                        let isParent="";
                        if(e.isParent==true){
                            //是否为父节点
                            isParent="1"
                        }else{
                            isParent="0"
                        }
                        areaOldIds.push(e.value+","+e.title+","+isParent+","+e.upperCode);
                    });

                    this.channelStatusOldCar='02';
                }
                this.basicTypeForm.mainCarOld=carOldIds;
                this.basicTypeForm.mainAreaOld=areaOldIds;

                console.log("渠道基本信息");
                if(this.basicTypeForm.channelId==undefined){
                    this.basicTypeForm.channelId=="";
                }
                /* if(this.basicTypeForm.customerManager == "" || this.basicTypeForm.customerManager == undefined ||this.basicTypeForm.customerManager == null){
                     this.channelCoopeCardealerTemp.associAccount = this.basicTypeForm.customerManagerOld;
                 }else{
                     this.channelCoopeCardealerTemp.associAccount = this.basicTypeForm.customerManager;
                 }*/


                //上线日期
                if(this.basicTypeForm.onlineDate != null || this.basicTypeForm.onlineDate !=""){
                    this.basicTypeForm.onlineDate =formatDate(this.basicTypeForm.onlineDate,"yyyy-MM-dd")
                }
                //新车有效期
                if(this.basicTypeForm.validDate != null || this.basicTypeForm.validDate !=""){
                    this.basicTypeForm.validDate[0] =formatDate(this.basicTypeForm.validDate[0],"yyyy-MM-dd")
                    this.basicTypeForm.validDate[1] =formatDate(this.basicTypeForm.validDate[1],"yyyy-MM-dd")
                }
                //二手车有效期
                if(this.basicTypeForm.validDateOld != null || this.basicTypeForm.validDateOld !=""){
                    this.basicTypeForm.validDateOld[0] =formatDate(this.basicTypeForm.validDateOld[0],"yyyy-MM-dd")
                    this.basicTypeForm.validDateOld[1] =formatDate(this.basicTypeForm.validDateOld[1],"yyyy-MM-dd")
                }
                //注册日期
                if(this.basicTypeForm.registrationDate != null || this.basicTypeForm.registrationDate !=""){
                    this.basicTypeForm.registrationDate =formatDate(this.basicTypeForm.registrationDate,"yyyy-MM-dd")
                }
                //新车先放有效期
                if(this.basicTypeForm.limitPutTime != null || this.basicTypeForm.limitPutTime !=""){
                    this.basicTypeForm.limitPutTime =formatDate(this.basicTypeForm.limitPutTime,"yyyy-MM-dd")
                }
                //新车后放有效期
                if(this.basicTypeForm.limitPledgeTime != null || this.basicTypeForm.limitPledgeTime !=""){
                    this.basicTypeForm.limitPledgeTime =formatDate(this.basicTypeForm.limitPledgeTime,"yyyy-MM-dd")
                }
                //二手车先放有效期
                if(this.basicTypeForm.limitPutTimeOld != null || this.basicTypeForm.limitPutTimeOld !=""){
                    this.basicTypeForm.limitPutTimeOld =formatDate(this.basicTypeForm.limitPutTimeOld,"yyyy-MM-dd")
                }
                //二手车后放有效期
                if(this.basicTypeForm.limitPledgeTimeOld != null || this.basicTypeForm.limitPledgeTimeOld !=""){
                    this.basicTypeForm.limitPledgeTimeOld =formatDate(this.basicTypeForm.limitPledgeTimeOld,"yyyy-MM-dd")
                }

                let param = {
                    //当前登陆者是否拥用新车角色权限:0否，1是(暂时测试给1、后续调整根据账户体系自动判断取值)
                    isNewCarRole:this.isNewCarRole,
                    //当前登陆者是否拥用二手车角色权限:0否，1是(暂时测试给1、后续调整根据账户体系自动判断取值)
                    isOldCarRole:this.isOldCarRole,

                    oldChannelId:this.basicTypeForm.oldChannelId,
                    channelCoopeCardealerTemp: {
                        channelId: this.basicTypeForm.channelId,
                        associAccount: this.basicTypeForm.customerManager,
                        associAccountOld: this.basicTypeForm.customerManagerOld,
                        cardealerType: "02",
                        status: '02',
                    },
                    //渠道基本信息
                    channelBaseInfoTemp: {
                        //渠道类型：直营车商
                        channelType:"02",
                        //主键
                        id:this.basicTypeForm.id,
                        //渠道代码
                        channelCode: this.basicTypeForm.channelCode,
                        //合作商全称
                        channelFullName:this.basicTypeForm.channelFullName.replace(/\s*/g,""),
                        //上线日期
                        onlineDate:this.basicTypeForm.onlineDate,
                        //统一社会信用代码
                        socUniCrtCode:this.basicTypeForm.socUniCrtCode.replace(/\s*/g,""),
                        //法人
                        legalPerson:this.basicTypeForm.legalPerson.replace(/\s*/g,""),
                        //法人身份证号
                        legalPersonIdCard:this.basicTypeForm.legalPersonIdCard,
                        //法人电话
                        legalPersonTel:this.basicTypeForm.legalPersonTel,
                        //实际控制人
                        actualController:this.basicTypeForm.actualController.replace(/\s*/g,""),
                        //实际控制人身份证号
                        actualControllerIdCard:this.basicTypeForm.actualControllerIdCard,
                        //实际控制人电话
                        actualControllerTel:this.basicTypeForm.actualControllerTel,
                        //管理员姓名
                        channelAdmin:this.basicTypeForm.channelAdmin.replace(/\s*/g,""),
                        //管理员电话
                        channelAdminTel:this.basicTypeForm.channelAdminTel,
                        //管理员邮箱
                        channelAdminMail:this.basicTypeForm.channelAdminMail,
                        //管理员证件号码
                        channelAdminIdCard:this.basicTypeForm.channelAdminIdCard,
                        //渠道管理员详细地址
                        channelAdminAddress:this.basicTypeForm.channelAdminAddressDetail,
                        //注册地址详细地址
                        channelAddress:this.basicTypeForm.channelAddressDetail,
                        //办公地址详细地址
                        officeAddress:this.basicTypeForm.officeAddressDetail,
                        //地址经纬度
                        longitude:this.basicTypeForm.longitude,
                        latitude:this.basicTypeForm.latitude,
                        //经纬度范围
                        longitudeLatitudeRange:this.basicTypeForm.longitudeLatitudeRange.replace(/\s*/g,""),
                        //公司人数
                        companiesNumber:this.basicTypeForm.companiesNumber,
                        //车商性质
                        carDealType:this.basicTypeForm.cardealType,
                        //经营场所面积
                        businessArea:this.basicTypeForm.businessArea,
                        //汇款对象
                        paymentObject:this.basicTypeForm.paymentObject,
                        //注册日期
                        registrationDate:this.basicTypeForm.registrationDate,
                        //主营品牌
                        mainBrand:this.basicTypeForm.mainBrand,
                        //注册资金
                        registeredCapital:this.basicTypeForm.registeredCapital,
                        //实收资本
                        subscribedCapital:this.basicTypeForm.subscribedCapital,
                        //渠道归属
                        channelBelong:this.basicTypeForm.channelBelong,
                        //业务类型;新车/二手车
                        delete:this.basicTypeForm.businessType,
                        businessType:this.basicTypeForm.businessType.join(','),

                        //资产净值
                        netAssetValue:this.basicTypeForm.netAssetValue,
                        //经营年限
                        businessLife:this.basicTypeForm.businessLife,
                        //GPS厂商授权
                        delete:this.basicTypeForm.gpsVendorAuthor,
                        gpsVendorAuthor:this.basicTypeForm.gpsVendorAuthor.join(','),

                        //资产负债率
                        assetLiabilityRatio:this.basicTypeForm.assetLiabilityRatio,
                        //上一年度经营利润
                        operatingProfit:this.basicTypeForm.operatingProfit,
                        //GPS安装方式
                        //delete:this.basicTypeForm.gpsInstalMode,
                        gpsInstalMode:this.basicTypeForm.gpsInstalMode,

                        //业绩
                        achievement:this.basicTypeForm.achievement,
                        //利润率增长率
                        proGrowthRate:this.basicTypeForm.proGrowthRate,
                        //销售收入增长率
                        saleIncreaseRate:this.basicTypeForm.saleIncreaseRate,
                        //流动比率
                        currentRatio:this.basicTypeForm.currentRatio,
                        //资产负债率
                        assetLiabilityRatio:this.basicTypeForm.assetLiabilityRatio,
                        //车辆类型;新车;二手车
                        //delete:this.basicTypeForm.carType,
                        //carType:this.basicTypeForm.carType.join(','),
                        //经纬度是否控制;是/否
                        longitudeLatitudeSwitch:this.basicTypeForm.longitudeLatitudeSwitch,
                        //业务人员关联车商;是/否
                        personRelCardealerSwitch:this.basicTypeForm.personRelCardealerSwitch,
                        //进件选择车商;是/否
                        choiceCardealerSwitch:this.basicTypeForm.choiceCardealerSwitch,
                        //层级最大数目
                        hierarchy:this.basicTypeForm.hierarchy,

                        channelStatus:this.channelStatusNewCar,
                        channelStatusOldCar:this.channelStatusOldCar,
                        accountInfo:this.basicTypeForm.accountInfo,

                    },
                    //管理员省市区
                    // channelAdminAddressValue:this.basicTypeForm.channelAdminAddressValue,
                    //注册地省市区
                    channelAddressValue:this.basicTypeForm.channelAddressValue,
                    //办公室省市区
                    //   officeAddressValue:this.basicTypeForm.officeAddressValue,
                    //新车授权区域
                    mainArea:this.basicTypeForm.mainArea,
                    //新车主营品牌
                    mainBrand:this.basicTypeForm.mainBrand,
                    //新车授权车型
                    mainCar:this.basicTypeForm.mainCar,

                    //新车授权区域
                    mainAreaOld:this.basicTypeForm.mainAreaOld,
                    //二手车授权车型
                    mainCarOld:this.basicTypeForm.mainCarOld,

                    //新车渠道风控信息
                    channelRiskInfoTemp: {
                        //业务类型：新车
                        businessType:"01",
                        qualityGrade:this.basicTypeForm.qualityGrade,
                        qualityStartDate:this.basicTypeForm.validDate[0],
                        qualityEndDate:this.basicTypeForm.validDate[1],

                        delete:this.basicTypeForm.carType,
                        carType:this.basicTypeForm.carType.join(','),
                        authRegionSwitch:this.basicTypeForm.authRegionSwitch,
                        authVehicleTypeSwitch:this.basicTypeForm.authVehicleTypeSwitch,
                        channelGrade:this.basicTypeForm.channelGrade,
                        channelDeposit:this.basicTypeForm.channelDeposit,
                        customerManager:this.basicTypeForm.customerManager,
                        accountMaxNum:this.basicTypeForm.accountMaxNum,
                    },
                    //二手车渠道风控信息
                    channelRiskInfoTempOld: {
                        //业务类型：二手车
                        businessType:"02",
                        qualityGrade:this.basicTypeForm.qualityGradeOld,
                        qualityStartDate:this.basicTypeForm.validDateOld[0],
                        qualityEndDate:this.basicTypeForm.validDateOld[1],

                        delete:this.basicTypeForm.carTypeOld,
                        carType:this.basicTypeForm.carTypeOld.join(','),
                        authRegionSwitch:this.basicTypeForm.authRegionSwitchOld,
                        authVehicleTypeSwitch:this.basicTypeForm.authVehicleTypeSwitchOld,
                        channelGrade:this.basicTypeForm.channelGradeOld,
                        channelDeposit:this.basicTypeForm.channelDepositOld,
                        customerManager:this.basicTypeForm.customerManagerOld,
                        accountMaxNum:this.basicTypeForm.accountMaxNumOld,
                    },
                    //新车渠道保证金信息
                    channelQuotaInfoTempList: [
                        //签放额度
                        {
                            //额度类型：签放额度
                            quotaType:"1",
                            //业务类型:新车
                            businessType:"01",
                            //是否控制额度
                            quotaControlSwitch:this.basicTypeForm.isLimitPut,
                            //额度金额
                            quotaAmount:this.basicTypeForm.limitPut,
                            //临时额度
                            tempQuota:this.basicTypeForm.temporaryLimitPut,
                            //有效期
                            validityTermEnd:this.basicTypeForm.limitPutTime,
                            //占用额度
                            occupiedQuota:this.basicTypeForm.limitPutTake,
                            //剩余额度
                            surplusQuota:this.basicTypeForm.limitPutResidue,

                        },
                        //先放后抵押额度
                        {
                            //额度类型：先放后抵押额度
                            quotaType:"2",
                            //业务类型
                            businessType:"01",
                            //是否控制额度
                            quotaControlSwitch:this.basicTypeForm.isLimitPledge,
                            //额度金额
                            quotaAmount:this.basicTypeForm.limitPledge,
                            //临时额度
                            tempQuota:this.basicTypeForm.temporaryLimitPledge,
                            //有效期
                            validityTermEnd:this.basicTypeForm.limitPledgeTime,
                            //占用额度
                            occupiedQuota:this.basicTypeForm.limitPledgeTake,
                            //剩余额度
                            surplusQuota:this.basicTypeForm.limitPledgeResidue,
                        }
                    ],

                    //二手车保证金信息
                    channelQuotaInfoTempOldList: [
                        //签放额度
                        {
                            //额度类型：签放额度
                            quotaType:"1",
                            //业务类型:新车
                            businessType:"02",
                            //是否控制额度
                            quotaControlSwitch:this.basicTypeForm.isLimitPutOld,
                            //额度金额
                            quotaAmount:this.basicTypeForm.limitPutOld,
                            //临时额度
                            tempQuota:this.basicTypeForm.temporaryLimitPutOld,
                            //有效期
                            validityTermEnd:this.basicTypeForm.limitPutTimeOld,
                            //占用额度
                            occupiedQuota:this.basicTypeForm.limitPutTakeOld,
                            //剩余额度
                            surplusQuota:this.basicTypeForm.limitPutResidueOld,

                        },
                        //先放后抵押额度
                        {
                            //额度类型：先放后抵押额度
                            quotaType:"2",
                            //业务类型
                            businessType:"02",
                            //是否控制额度
                            quotaControlSwitch:this.basicTypeForm.isLimitPledgeOld,
                            //额度金额
                            quotaAmount:this.basicTypeForm.limitPledgeOld,
                            //临时额度
                            tempQuota:this.basicTypeForm.temporaryLimitPledgeOld,
                            //有效期
                            validityTermEnd:this.basicTypeForm.limitPledgeTimeOld,
                            //占用额度
                            occupiedQuota:this.basicTypeForm.limitPledgeTakeOld,
                            //剩余额度
                            surplusQuota:this.basicTypeForm.limitPledgeResidueOld,
                        }
                    ],
                }


                //黑名单保存验证改渠道是否在黑名单信息表中
                let blackParams={
                    //黑名单类型：直营车商
                    blacklistType:'05',
                    //黑名单名称
                    blackName:this.basicTypeForm.channelFullName,
                    //证件类型：统一社会信息代码
                    idType:'02',
                    //统一社会信用代码
                    idCode:this.basicTypeForm.socUniCrtCode,
                }
                checkBlack(blackParams).then(res => {
                    if (res.code === "0000") {
                        //黑名单判断字段:是
                        if(res.weatherBlackList === "1"){
                            this.$Message.error("该车商已存在黑名单信息库中！");
                            this.$parent.spinShow=false;
                        }else {

                            if(this.basicTypeForm.id !=null && this.basicTypeForm.id !="" && this.basicTypeForm.id != undefined && this.OldStatus !="06"){
                                updateChannel(param).then(res => {
                                    if (res.code === "0000") {
                                        this.$Message.success("保存成功");

                                        this.basicTypeForm.id=res.data[0].id;
                                        this.basicTypeForm.oldChannelId=res.data[1].channelId;

                                        //账户页面信息更新
                                        this.$parent.getAccountInfo(this.basicTypeForm.id);
                                        //回显业务员
                                        this.getAllSaleManByChannelId();
                                        //基本信息处理
                                        this.getChannelInfo(res.data[0].id);
                                        this.$parent.setchannelId(res.data[0].id);
                                        this.getMainAreaList(res.data[0].id);
                                        this.getBaseTreeList(res.data[0].id);
                                        //this.getCarsTreeList(res.data[0].id);
                                        this.$parent.spinShow=false;

                                    }
                                }).catch(() => {
                                    this.$parent.spinShow=false;
                                });
                            }else {
                                addChannel(param).then(res => {
                                    if (res.code === "0000") {
                                        this.$Message.success("保存成功");

                                        //基本信息处理
                                        this.basicTypeForm.id=res.data[0].id;
                                        this.basicTypeForm.oldChannelId=res.data[1].channelId;
                                        //账户页面信息更新
                                        this.$parent.getAccountInfo(this.basicTypeForm.id);
                                        //回显业务员
                                        this.getAllSaleManByChannelId();

                                        this.getChannelInfo(res.data[0].id);
                                        this.$parent.setchannelId(res.data[0].id);
                                        this.getMainAreaList(res.data[0].id);
                                        this.getBaseTreeList(res.data[0].id);
                                        //this.getCarsTreeList(res.data[0].id);
                                        this.$parent.spinShow=false;
                                    }
                                }).catch(() => {
                                    this.$parent.spinShow=false;
                                });
                            }

                        }
                    }
                }).catch(() => {
                    this.$Message.error("未知错误,请联系管理员！");
                    this.$parent.spinShow=false;
                });

            },

            //直营车商提交审核
            basicSubmit(){
                //提交之前先查一下汇款账号信息 必须要有汇款账号信息
                this.channelStatus="01";
                this.channelStatusNewCar="";
                this.channelStatusOldCar="";
                let channelId = this.basicTypeForm.id;
                console.log(channelId)
                if(this.basicTypeForm.accountInfo != "0"){
                    if(channelId ==null || channelId=="" || channelId==undefined){
                        this.$Message.error("请先保存基本信息");
                        console.log("请先保存基本信息")
                        return false;
                    }

                    getAccountInfoByChannelId(channelId).then(res => {
                        if (res.code === "0000") {
                            this.submitBasicInfo();
                        }
                    })
                }else {
                    this.submitBasicInfo();
                }
                console.log("渠道基本信息提交结束！");
            },

            submitBasicInfo(){
                this.channelStatus="01";
                this.channelStatusNewCar="";
                this.channelStatusOldCar="";

                //有效期表单验证
                //this.verifyLimitDate();
                this.$refs.basicTypeForm.validate(valid => {
                    this.$parent.spinShow=true;
                    console.log(valid);
                    if (valid) {

                        let brandIds = [];
                        try {
                            let selectedBrandNodes = this.$refs.baseTree.getCheckedAndIndeterminateNodes();
                            selectedBrandNodes.forEach(function (e) {
                                let index = selectedBrandNodes.findIndex(m => m.indeterminate==false && m.code === e.upperCode)
                                if(index < 0) {
                                    if(e.indeterminate==undefined){
                                        e.indeterminate=" ";
                                    }
                                    if(e.spellCode==undefined){
                                        e.spellCode=" ";
                                    }
                                    brandIds.push(e.code+","+e.title+","+e.indeterminate+","+e.carLevel+","+e.spellCode);
                                    if(e.carLevel=="0" && e.indeterminate==false){
                                        throw Error();
                                    }
                                }
                            });
                        }catch (e) {
                        }
                        this.basicTypeForm.mainBrand=brandIds;

                        let areaIds = [];
                        let carIds = [];
                        //新车角色权限 && 而且当前页面存在新车表单
                        if(this.isNewCarRole=="1"){
                            let selectedAreaNodes = this.$refs.tree.getCheckedAndIndeterminateNodes();
                            selectedAreaNodes.forEach(function (e) {
                                let isParent="";
                                if(e.isParent==true){
                                    //是否为父节点
                                    isParent="1"
                                }else{
                                    isParent="0"
                                }
                                areaIds.push(e.value+","+e.title+","+isParent+","+e.upperCode);
                            });
                            if(areaIds.length===0 && this.basicTypeForm.authRegionSwitch=="1"){
                                this.$Message.error("请勾选新车授权区域");
                                this.$parent.loadingSave=false;
                                this.$parent.spinShow=false;
                                return false;
                            }

                            try {
                                let selectedCarIdsNodes = this.$refs.carstree.getCheckedAndIndeterminateNodes();
                                selectedCarIdsNodes.forEach(function (e) {
                                    let index = selectedCarIdsNodes.findIndex(m => m.indeterminate==false && m.code === e.upperCode)
                                    if(index < 0) {
                                        if(e.indeterminate==undefined){
                                            e.indeterminate=" ";
                                        }
                                        if(e.spellCode==undefined){
                                            e.spellCode=" ";
                                        }
                                        carIds.push(e.code+","+e.title+","+e.upperCode+","+e.indeterminate+","+e.carLevel+","+e.spellCode+","+e.carType);
                                        if(e.carLevel=="0" && e.indeterminate==false){
                                            throw Error();
                                        }
                                    }
                                });
                            }catch (e) {
                            }
                            if(carIds.length===0 && this.basicTypeForm.authVehicleTypeSwitch=="1"){
                                this.$Message.error("请勾新车授权车型");
                                this.$parent.loadingSave=false;
                                this.$parent.spinShow=false;
                                return false;
                            }
                            this.channelStatusNewCar=this.channelStatus;
                        }
                        this.basicTypeForm.mainArea=areaIds;
                        this.basicTypeForm.mainCar=carIds;

                        let carOldIds = [];
                        let areaOldIds = [];
                        //二手车角色权限 && 而且当前页面存在二手车表单
                        if(this.isOldCarRole=="1"){
                            try {
                                let selectedCarOLdIdsNodes = this.$refs.carstreeOld.getCheckedAndIndeterminateNodes();
                                selectedCarOLdIdsNodes.forEach(function (e) {
                                    let index = selectedCarOLdIdsNodes.findIndex(m => m.indeterminate==false && m.code === e.upperCode)
                                    if(index < 0) {
                                        if(e.indeterminate==undefined){
                                            e.indeterminate=" ";
                                        }
                                        if(e.spellCode==undefined){
                                            e.spellCode=" ";
                                        }
                                        carOldIds.push(e.code+","+e.title+","+e.upperCode+","+e.indeterminate+","+e.carLevel+","+e.spellCode+","+e.carType);
                                        if(e.carLevel=="0" && e.indeterminate==false){
                                            throw Error();
                                        }
                                    }
                                });
                            }catch (e) {
                            }
                            if(carOldIds.length==0 && this.basicTypeForm.authVehicleTypeSwitchOld=="1"){
                                this.$Message.error("请勾二手车授权车型");
                                this.$parent.loadingSave=false;
                                this.$parent.spinShow=false;
                                return false;
                            }
                            let selectedAreaOldNodes = this.$refs.treeOld.getCheckedAndIndeterminateNodes();
                            selectedAreaOldNodes.forEach(function (e) {
                                let isParent="";
                                if(e.isParent==true){
                                    //是否为父节点
                                    isParent="1"
                                }else{
                                    isParent="0"
                                }
                                areaOldIds.push(e.value+","+e.title+","+isParent+","+e.upperCode);
                            });
                            if(areaOldIds.length==0 && this.basicTypeForm.authRegionSwitchOld=="1"){
                                this.$Message.error("请勾选二手车授权区域");
                                this.$parent.loadingSave=false;
                                this.$parent.spinShow=false;
                                return false;
                            }
                            this.channelStatusOldCar=this.channelStatus;
                        }
                        this.basicTypeForm.mainCarOld=carOldIds;
                        this.basicTypeForm.mainAreaOld=areaOldIds;

                        console.log("渠道基本信息");
                        if(this.basicTypeForm.channelId==undefined){
                            this.basicTypeForm.channelId=="";
                        }
                        //上线日期
                        if(this.basicTypeForm.onlineDate != null || this.basicTypeForm.onlineDate !=""){
                            this.basicTypeForm.onlineDate =formatDate(this.basicTypeForm.onlineDate,"yyyy-MM-dd")
                        }
                        //新车有效期
                        if(this.basicTypeForm.validDate != null || this.basicTypeForm.validDate !=""){
                            this.basicTypeForm.validDate[0] =formatDate(this.basicTypeForm.validDate[0],"yyyy-MM-dd")
                            this.basicTypeForm.validDate[1] =formatDate(this.basicTypeForm.validDate[1],"yyyy-MM-dd")
                        }
                        //二手车有效期
                        if(this.basicTypeForm.validDateOld != null || this.basicTypeForm.validDateOld !=""){
                            this.basicTypeForm.validDateOld[0] =formatDate(this.basicTypeForm.validDateOld[0],"yyyy-MM-dd")
                            this.basicTypeForm.validDateOld[1] =formatDate(this.basicTypeForm.validDateOld[1],"yyyy-MM-dd")
                        }
                        //注册日期
                        if(this.basicTypeForm.registrationDate != null || this.basicTypeForm.registrationDate !=""){
                            this.basicTypeForm.registrationDate =formatDate(this.basicTypeForm.registrationDate,"yyyy-MM-dd")
                        }
                        //新车先放有效期
                        if(this.basicTypeForm.limitPutTime != null || this.basicTypeForm.limitPutTime !=""){
                            this.basicTypeForm.limitPutTime =formatDate(this.basicTypeForm.limitPutTime,"yyyy-MM-dd")
                        }
                        //新车后放有效期
                        if(this.basicTypeForm.limitPledgeTime != null || this.basicTypeForm.limitPledgeTime !=""){
                            this.basicTypeForm.limitPledgeTime =formatDate(this.basicTypeForm.limitPledgeTime,"yyyy-MM-dd")
                        }
                        //二手车先放有效期
                        if(this.basicTypeForm.limitPutTimeOld != null || this.basicTypeForm.limitPutTimeOld !=""){
                            this.basicTypeForm.limitPutTimeOld =formatDate(this.basicTypeForm.limitPutTimeOld,"yyyy-MM-dd")
                        }
                        //二手车后放有效期
                        if(this.basicTypeForm.limitPledgeTimeOld != null || this.basicTypeForm.limitPledgeTimeOld !=""){
                            this.basicTypeForm.limitPledgeTimeOld =formatDate(this.basicTypeForm.limitPledgeTimeOld,"yyyy-MM-dd")
                        }


                        let param = {
                            //当前登陆者是否拥用新车角色权限:0否，1是(暂时测试给1、后续调整根据账户体系自动判断取值)
                            isNewCarRole:this.isNewCarRole,
                            //当前登陆者是否拥用二手车角色权限:0否，1是(暂时测试给1、后续调整根据账户体系自动判断取值)
                            isOldCarRole:this.isOldCarRole,

                            oldChannelId:this.basicTypeForm.oldChannelId,
                            channelCoopeCardealerTemp: {
                                channelId: this.basicTypeForm.channelId,
                                associAccount: this.basicTypeForm.customerManager,
                                associAccountOld: this.basicTypeForm.customerManagerOld,
                                cardealerType: "02",
                                status: this.channelStatus,
                            },
                            //渠道基本信息f
                            channelBaseInfoTemp: {
                                //渠道类型：直营车商
                                channelType:"02",
                                //主键
                                id:this.basicTypeForm.id,
                                //渠道代码
                                channelCode: this.basicTypeForm.channelCode,
                                //合作商全称
                                channelFullName:this.basicTypeForm.channelFullName.replace(/\s*/g,""),
                                //上线日期
                                onlineDate:this.basicTypeForm.onlineDate,
                                //统一社会信用代码
                                socUniCrtCode:this.basicTypeForm.socUniCrtCode.replace(/\s*/g,""),
                                //法人
                                legalPerson:this.basicTypeForm.legalPerson.replace(/\s*/g,""),
                                //法人身份证号
                                legalPersonIdCard:this.basicTypeForm.legalPersonIdCard,
                                //法人电话
                                legalPersonTel:this.basicTypeForm.legalPersonTel,
                                //实际控制人
                                actualController:this.basicTypeForm.actualController.replace(/\s*/g,""),
                                //实际控制人身份证号
                                actualControllerIdCard:this.basicTypeForm.actualControllerIdCard,
                                //实际控制人电话
                                actualControllerTel:this.basicTypeForm.actualControllerTel,
                                //管理员姓名
                                channelAdmin:this.basicTypeForm.channelAdmin.replace(/\s*/g,""),
                                //管理员电话
                                channelAdminTel:this.basicTypeForm.channelAdminTel,
                                //管理员邮箱
                                channelAdminMail:this.basicTypeForm.channelAdminMail,
                                //管理员证件号码
                                channelAdminIdCard:this.basicTypeForm.channelAdminIdCard,
                                //渠道管理员详细地址
                                channelAdminAddress:this.basicTypeForm.channelAdminAddressDetail,
                                //注册地址详细地址
                                channelAddress:this.basicTypeForm.channelAddressDetail,
                                //办公地址详细地址
                                officeAddress:this.basicTypeForm.officeAddressDetail,
                                //地址经纬度
                                longitude:this.basicTypeForm.longitude,
                                latitude:this.basicTypeForm.latitude,
                                //经纬度范围
                                longitudeLatitudeRange:this.basicTypeForm.longitudeLatitudeRange.replace(/\s*/g,""),
                                //公司人数
                                companiesNumber:this.basicTypeForm.companiesNumber,
                                //车商性质
                                carDealType:this.basicTypeForm.cardealType,
                                //经营场所面积
                                businessArea:this.basicTypeForm.businessArea,
                                //汇款对象
                                paymentObject:this.basicTypeForm.paymentObject,
                                //注册日期
                                registrationDate:this.basicTypeForm.registrationDate,
                                //主营品牌
                                mainBrand:this.basicTypeForm.mainBrand,
                                //注册资金
                                registeredCapital:this.basicTypeForm.registeredCapital,
                                //实收资本
                                subscribedCapital:this.basicTypeForm.subscribedCapital,
                                //渠道归属
                                channelBelong:this.basicTypeForm.channelBelong,
                                //业务类型;新车/二手车
                                delete:this.basicTypeForm.businessType,
                                businessType:this.basicTypeForm.businessType.join(','),

                                //资产净值
                                netAssetValue:this.basicTypeForm.netAssetValue,
                                //经营年限
                                businessLife:this.basicTypeForm.businessLife,
                                //GPS厂商授权
                                delete:this.basicTypeForm.gpsVendorAuthor,
                                gpsVendorAuthor:this.basicTypeForm.gpsVendorAuthor.join(','),

                                //资产负债率
                                assetLiabilityRatio:this.basicTypeForm.assetLiabilityRatio,
                                //上一年度经营利润
                                operatingProfit:this.basicTypeForm.operatingProfit,
                                //GPS安装方式
                                //delete:this.basicTypeForm.gpsInstalMode,
                                gpsInstalMode:this.basicTypeForm.gpsInstalMode,

                                //业绩
                                achievement:this.basicTypeForm.achievement,
                                //利润率增长率
                                proGrowthRate:this.basicTypeForm.proGrowthRate,
                                //销售收入增长率
                                saleIncreaseRate:this.basicTypeForm.saleIncreaseRate,
                                //流动比率
                                currentRatio:this.basicTypeForm.currentRatio,
                                //资产负债率
                                assetLiabilityRatio:this.basicTypeForm.assetLiabilityRatio,
                                //车辆类型;新车;二手车
                                //delete:this.basicTypeForm.carType,
                                //carType:this.basicTypeForm.carType.join(','),
                                //经纬度是否控制;是/否
                                longitudeLatitudeSwitch:this.basicTypeForm.longitudeLatitudeSwitch,
                                //业务人员关联车商;是/否
                                personRelCardealerSwitch:this.basicTypeForm.personRelCardealerSwitch,
                                //进件选择车商;是/否
                                choiceCardealerSwitch:this.basicTypeForm.choiceCardealerSwitch,
                                //层级最大数目
                                hierarchy:this.basicTypeForm.hierarchy,

                                channelStatus:this.channelStatusNewCar,
                                channelStatusOldCar:this.channelStatusOldCar,
                                accountInfo:this.basicTypeForm.accountInfo,

                            },
                            //管理员省市区
                            // channelAdminAddressValue:this.basicTypeForm.channelAdminAddressValue,
                            //注册地省市区
                            channelAddressValue:this.basicTypeForm.channelAddressValue,
                            //办公室省市区
                            //   officeAddressValue:this.basicTypeForm.officeAddressValue,
                            //新车授权区域
                            mainArea:this.basicTypeForm.mainArea,
                            //新车主营品牌
                            mainBrand:this.basicTypeForm.mainBrand,
                            //新车授权车型
                            mainCar:this.basicTypeForm.mainCar,

                            //新车授权区域
                            mainAreaOld:this.basicTypeForm.mainAreaOld,
                            //二手车授权车型
                            mainCarOld:this.basicTypeForm.mainCarOld,

                            //新车渠道风控信息
                            channelRiskInfoTemp: {
                                //业务类型：新车
                                businessType:"01",
                                qualityGrade:this.basicTypeForm.qualityGrade,
                                qualityStartDate:this.basicTypeForm.validDate[0],
                                qualityEndDate:this.basicTypeForm.validDate[1],

                                delete:this.basicTypeForm.carType,
                                carType:this.basicTypeForm.carType.join(','),
                                authRegionSwitch:this.basicTypeForm.authRegionSwitch,
                                authVehicleTypeSwitch:this.basicTypeForm.authVehicleTypeSwitch,
                                channelGrade:this.basicTypeForm.channelGrade,
                                channelDeposit:this.basicTypeForm.channelDeposit,
                                customerManager:this.basicTypeForm.customerManager,
                                accountMaxNum:this.basicTypeForm.accountMaxNum,
                            },
                            //二手车渠道风控信息
                            channelRiskInfoTempOld: {
                                //业务类型：二手车
                                businessType:"02",
                                qualityGrade:this.basicTypeForm.qualityGradeOld,
                                qualityStartDate:this.basicTypeForm.validDateOld[0],
                                qualityEndDate:this.basicTypeForm.validDateOld[1],

                                delete:this.basicTypeForm.carTypeOld,
                                carType:this.basicTypeForm.carTypeOld.join(','),
                                authRegionSwitch:this.basicTypeForm.authRegionSwitchOld,
                                authVehicleTypeSwitch:this.basicTypeForm.authVehicleTypeSwitchOld,
                                channelGrade:this.basicTypeForm.channelGradeOld,
                                channelDeposit:this.basicTypeForm.channelDepositOld,
                                customerManager:this.basicTypeForm.customerManagerOld,
                                accountMaxNum:this.basicTypeForm.accountMaxNumOld,
                            },
                            //新车渠道保证金信息
                            channelQuotaInfoTempList: [
                                //签放额度
                                {
                                    //额度类型：签放额度
                                    quotaType:"1",
                                    //业务类型:新车
                                    businessType:"01",
                                    //是否控制额度
                                    quotaControlSwitch:this.basicTypeForm.isLimitPut,
                                    //额度金额
                                    quotaAmount:this.basicTypeForm.limitPut,
                                    //临时额度
                                    tempQuota:this.basicTypeForm.temporaryLimitPut,
                                    //有效期
                                    validityTermEnd:this.basicTypeForm.limitPutTime,
                                    //占用额度
                                    occupiedQuota:this.basicTypeForm.limitPutTake,
                                    //剩余额度
                                    surplusQuota:this.basicTypeForm.limitPutResidue,

                                },
                                //先放后抵押额度
                                {
                                    //额度类型：先放后抵押额度
                                    quotaType:"2",
                                    //业务类型
                                    businessType:"01",
                                    //是否控制额度
                                    quotaControlSwitch:this.basicTypeForm.isLimitPledge,
                                    //额度金额
                                    quotaAmount:this.basicTypeForm.limitPledge,
                                    //临时额度
                                    tempQuota:this.basicTypeForm.temporaryLimitPledge,
                                    //有效期
                                    validityTermEnd:this.basicTypeForm.limitPledgeTime,
                                    //占用额度
                                    occupiedQuota:this.basicTypeForm.limitPledgeTake,
                                    //剩余额度
                                    surplusQuota:this.basicTypeForm.limitPledgeResidue,
                                }
                            ],

                            //二手车保证金信息
                            channelQuotaInfoTempOldList: [
                                //签放额度
                                {
                                    //额度类型：签放额度
                                    quotaType:"1",
                                    //业务类型:新车
                                    businessType:"02",
                                    //是否控制额度
                                    quotaControlSwitch:this.basicTypeForm.isLimitPutOld,
                                    //额度金额
                                    quotaAmount:this.basicTypeForm.limitPutOld,
                                    //临时额度
                                    tempQuota:this.basicTypeForm.temporaryLimitPutOld,
                                    //有效期
                                    validityTermEnd:this.basicTypeForm.limitPutTimeOld,
                                    //占用额度
                                    occupiedQuota:this.basicTypeForm.limitPutTakeOld,
                                    //剩余额度
                                    surplusQuota:this.basicTypeForm.limitPutResidueOld,

                                },
                                //先放后抵押额度
                                {
                                    //额度类型：先放后抵押额度
                                    quotaType:"2",
                                    //业务类型
                                    businessType:"02",
                                    //是否控制额度
                                    quotaControlSwitch:this.basicTypeForm.isLimitPledgeOld,
                                    //额度金额
                                    quotaAmount:this.basicTypeForm.limitPledgeOld,
                                    //临时额度
                                    tempQuota:this.basicTypeForm.temporaryLimitPledgeOld,
                                    //有效期
                                    validityTermEnd:this.basicTypeForm.limitPledgeTimeOld,
                                    //占用额度
                                    occupiedQuota:this.basicTypeForm.limitPledgeTakeOld,
                                    //剩余额度
                                    surplusQuota:this.basicTypeForm.limitPledgeResidueOld,
                                }
                            ],
                        }


                        //黑名单保存验证改渠道是否在黑名单信息表中
                        let blackParams={
                            //黑名单类型：直营车商
                            blacklistType:'05',
                            //黑名单名称
                            blackName:this.basicTypeForm.channelFullName,
                            //证件类型：统一社会信息代码
                            idType:'02',
                            //统一社会信用代码
                            idCode:this.basicTypeForm.socUniCrtCode,
                        }
                        checkBlack(blackParams).then(res => {
                            if (res.code === "0000") {
                                //黑名单判断字段:是
                                if(res.weatherBlackList === "1"){
                                    this.$Message.error("该车商已存在黑名单信息库中！");
                                    this.$parent.spinShow=false;
                                }else {

                                    if(this.basicTypeForm.id !=null && this.basicTypeForm.id !="" && this.basicTypeForm.id != undefined && this.OldStatus !="06"){
                                        updateChannel(param).then(res => {
                                            if (res.code === "0000") {
                                                this.basicTypeForm.id=res.data[0].id;
                                                this.basicTypeForm.oldChannelId=res.data[1].channelId;
                                                //账户页面信息更新
                                                this.$parent.getAccountInfo(this.basicTypeForm.id);
                                                //回显业务员
                                                this.getAllSaleManByChannelId();

                                                //跳转到审核页面
                                                /*let params = {
                                                    cardealerId: this.basicTypeForm.id,
                                                    channelId: this.basicTypeForm.channelId,
                                                };
                                                this.afs.newTab(
                                                    this,
                                                    'projects/afs-channel/pages/car-dealer/direct-car-dealer/direct-car-dealer-approve/directCarDealerApproveDetail',
                                                    '直营车商'+this.basicTypeForm.channelFullName+"审核",
                                                    'ios-add',
                                                    params,
                                                    'direct-cardealer-approve'+this.basicTypeForm.id,
                                                    [],
                                                    true);*/
                                                this.$Message.success("提交成功");
                                                this.afs.closeTab(this);
                                                this.$router.push({path: '/directCarDealerList'});

                                                //基本信息处理
                                                this.getChannelInfo(res.data[0].id);
                                                this.$parent.setchannelId(res.data[0].id);
                                                // this.getMainAreaList(res.data[0].id);
                                                this.getChannelId();
                                                this.getBaseTreeList(res.data[0].id);
                                                //this.getCarsTreeList(res.data[0].id);
                                                this.$parent.spinShow=false;

                                            }
                                        }).catch(() => {
                                            this.$parent.spinShow=false;
                                        });
                                    }else {
                                        addChannel(param).then(res => {
                                            if (res.code === "0000") {

                                                //基本信息处理
                                                this.basicTypeForm.id=res.data[0].id;
                                                this.basicTypeForm.oldChannelId=res.data[1].channelId;
                                                //账户页面信息更新
                                                this.$parent.getAccountInfo(this.basicTypeForm.id);
                                                //回显业务员
                                                this.getAllSaleManByChannelId();

                                                this.$Message.success("提交成功");
                                                this.afs.closeTab(this);
                                                this.$router.push({path: '/directCarDealerList'});
                                                this.getChannelInfo(res.data[0].id);
                                                this.$parent.setchannelId(res.data[0].id);
                                                // this.getMainAreaList(res.data[0].id);
                                                this.getChannelId();
                                                this.getBaseTreeList(res.data[0].id);
                                                //this.getCarsTreeList(res.data[0].id);
                                                this.$parent.spinShow=false;
                                            }
                                        }).catch(() => {
                                            this.$parent.spinShow=false;
                                        });
                                    }

                                }
                            }
                        }).catch(() => {
                            this.$Message.error("未知错误,请联系管理员！");
                            this.$parent.spinShow=false;
                        });


                    }else{
                        this.$Message.error('请补全基本信息');
                        for (let i in this.$refs.basicTypeForm.fields) {
                            if (this.$refs.basicTypeForm.fields[i].validateState === "error") {
                                this.$refs.basicTypeForm.fields[i].$el.scrollIntoView({
                                    block: "center",
                                    behavior: "smooth",
                                    inline: "center"
                                });
                                break;
                            }
                        }
                        this.$parent.spinShow=false;
                    }
                });
                console.log("submitBasicInfo");
            },

            OnlyCheckBlack(){
                //黑名单保存验证改渠道是否在黑名单信息表中
                if(this.basicTypeForm.socUniCrtCode == null || this.basicTypeForm.socUniCrtCode == undefined || this.basicTypeForm.socUniCrtCode ==""){
                    return false;
                }
                let blackParams={
                    //黑名单类型：直营车商
                    blacklistType:'05',
                    //黑名单名称
                    blackName:this.basicTypeForm.channelFullName,
                    //证件类型：统一社会信息代码
                    idType:'02',
                    //统一社会信用代码
                    idCode:this.basicTypeForm.socUniCrtCode,
                }
                checkBlack(blackParams).then(res => {
                    if (res.code === "0000") {
                        //黑名单判断字段:是
                        if(res.weatherBlackList === "1"){
                            this.$Message.error("该车商已存在黑名单信息库中！");
                        }else {
                            this.inBlackList=false;
                        }
                    }
                }).catch(() => {
                    this.$Message.error("未知错误,请联系管理员！");
                });
            },

            //验证黑名单
            checkBlack(){
                if(this.basicTypeForm.socUniCrtCode == null || this.basicTypeForm.socUniCrtCode == undefined || this.basicTypeForm.socUniCrtCode ==""){
                    return false;
                }
                //黑名单保存验证改渠道是否在黑名单信息表中
                let blackParams={
                    //黑名单类型：直营车商
                    blacklistType:'05',
                    //黑名单名称
                    blackName:this.basicTypeForm.channelFullName,
                    //证件类型：统一社会信息代码
                    idType:'02',
                    //统一社会信用代码
                    idCode:this.basicTypeForm.socUniCrtCode,
                }

                let param={
                    //社会统一信用代码
                    id:this.basicTypeForm.id,
                    socUniCrtCode:this.basicTypeForm.socUniCrtCode,
                    channelId:this.basicTypeForm.channelId,
                }

                checkBlack(blackParams).then(res => {
                    if (res.code === "0000") {
                        //黑名单判断字段:是
                        if(res.weatherBlackList === "1"){
                            this.$Message.error("该车商已存在黑名单信息库中！");
                            this.$parent.spinShow=false;
                        }else if(this.basicTypeForm.channelId != null && this.basicTypeForm.channelId != "" && this.basicTypeForm.channelId != undefined && this.typeCode== "01" ){
                            this.inBlackList=false;
                            //查重
                            checkCooper(param).then(res => {
                                if (res.code === "0000") {
                                    if(res.data == "00"){
                                        this.$Message.error("合作商与此车商已存在合作关系！");
                                    }
                                }
                            })
                        }
                    }
                }).catch(() => {
                    this.$Message.error("未知错误,请联系管理员！");
                });
            },
            blackChannel(){
                console.log("黑名单申请开始！");
                this.modalTitle="确认将合作商加入黑名单吗？";
                this.blackApplyVisible=true;
            },
            cancel() {
                //关闭黑名单窗口
                this.blackApplyVisible = false;
            },
            //申请加入黑名单
            join(){
                console.log("渠道黑名单保存开始！");
                console.log(this.blackApplyForm.blacklistReason);
                if (this.blackApplyForm.blacklistReason !="" && this.blackApplyForm.blacklistReason != null && this.blackApplyForm.blacklistReason != undefined) {
                    let params={
                        //黑名单类型：直营车商
                        blacklistType:'05',
                        //黑名单名称
                        blackName:this.basicTypeForm.channelFullName,
                        //证件类型：组织机构代码
                        idType:'02',
                        idCode:this.basicTypeForm.socUniCrtCode,
                        //黑名单原因
                        blacklistReason:this.blackApplyForm.blacklistReason,
                        carDealers: "02"
                    }
                    saveBlack(params).then(res => {
                        if (res.code === "0000") {
                            this.$Message.success("申请成功！");
                            this.cancel();
                        }
                    }).catch(() => {
                        this.$Message.error("申请失败！");
                    });
                }else {
                    this.$Message.error("请输入加入黑名单原因！");
                    return false;
                }

            },
            changeSelect() {

            },
            selectChange(){

            },
            readOnlyInfo(b) {
                let _this=this;
                this.$nextTick(()=>{
                    _this.typeCode=b;
                })
            },
            changeTypeCode(v){
                this.typeCode2=v;
            },



            //主营品牌
            getBaseTreeList(v){
                let param = {
                    type:[],
                }
                getBrandTree(param).then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        // 仅展开指定级数 默认一级
                        let expandLevel = this.carLevel;
                        res.data.forEach(function (e) {
                            if (expandLevel == "0") {
                                if (e.carLevel === "0") {
                                    e.expand = true;
                                }
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (c.carLevel === "1") {
                                            c.expand = false;
                                        }
                                    });
                                }
                            } else {
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (expandLevel == 0) {
                                            if (c.carLevel === "1") {
                                                c.expand = false;
                                            }
                                        }
                                    });
                                }
                            }
                        });
                        let mainCarSearchTemp = deepClone(res.data);
                        if(v!=null && v!="" && v!= undefined){
                            //根据渠道id查询主营品牌
                            getCarBrandById(v).then(resMainCar => {
                                this.loading = false;
                                if (resMainCar.code === "0000") {
                                    let cars = resMainCar.data;
                                    this.checkMainCarTree(mainCarSearchTemp, cars);
                                    this.baseData=mainCarSearchTemp;
                                }
                            })
                        }else{
                            this.baseData= deepClone(res.data);
                        }
                    }
                });
            },
            // 递归判断子节点
            checkMainCarTree(mainCarData, cars) {
                let that = this;
                mainCarData.forEach(function (p) {
                    if (that.hasMainCar(p, cars)=="0") {
                        //层级表示第一层级，第二层级不用勾选
                        p.checked = false;
                    }else if(that.hasMainCar(p, cars)=="1") {
                        p.checked = true;
                    }else if(that.hasMainCar(p, cars)=="2"){
                        if(p.carLevel=="0"){
                            p.checked = false;
                        }else{
                            p.checked = true;
                        }
                    }else{
                        if(p.carLevel=="0" || p.carLevel=="1" ){
                            p.checked = false;
                        }else{
                            p.checked = true;
                        }
                    }
                    if (p.children && p.children.length > 0) {
                        that.checkMainCarTree(p.children, cars);
                    }
                });
            },

            //判断主营品牌节点勾选
            hasMainCar(p, cars) {
                //flag 等于 0 表示code相等
                let flag = "0";
                for (let i = 0; i < cars.length; i++) {
                    if (p.code === cars[i].code && cars[i].code=="00" &&  cars[i].indeterminate=="false") {
                        //表示一级品牌名称非半选状态：即为全选状态，数据库只有一笔数据
                        flag="1";
                        if(cars[i].indeterminate=="false"){
                            p.indeterminate=false;
                        }else{
                            p.indeterminate=true;
                        }
                        break;
                    }else if (p.code === cars[i].code &&  cars[i].indeterminate=="false") {
                        //表示二级品牌非半选状态：即为全选状态，数据库只有一笔数据
                        flag = "2";
                        if(cars[i].indeterminate=="false"){
                            p.indeterminate=false;
                        }else{
                            p.indeterminate=true;
                        }
                        break;
                    }else if (p.code === cars[i].code){
                        //表示三级品牌非半选状态：即为全选状态，数据库只有一笔数据
                        flag = "3";
                        p.indeterminate=true;
                        break;
                    }
                }
                return flag;
            },


            //授权区域
            getMainAreaList(v){
                getAllAddressList().then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        // 仅展开指定级数 默认一级
                        let expandLevel = this.expandLevel;
                        res.data.forEach(function (e) {
                            if (expandLevel == "0") {
                                if (e.addrLevel === "0") {
                                    e.expand = true;
                                }
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (c.addrLevel === "1") {
                                            c.expand = false;
                                        }
                                    });
                                }
                            } else {
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (expandLevel == 1) {
                                            if (c.addrLevel === "1") {
                                                c.expand = false;
                                            }
                                        }
                                    });
                                }
                            }
                        });
                        this.areasData= deepClone(res.data);
                        this.areasDataOld =deepClone(res.data);
                        if(v!=null && v!="" && v!= undefined){
                            //根据渠道id查询授权区域
                            getMainAreaById(v).then(resMainArea => {
                                this.loading = false;
                                if (resMainArea.code === "0000") {
                                    let areas = resMainArea.data;
                                    areas.forEach((item, i) => {
                                        if(item.businessType=="01"){
                                            //新车
                                            this.checkAreaTree(this.areasData, areas,"01");
                                        }else{
                                            //二手车
                                            this.checkAreaTree(this.areasDataOld, areas,"02");
                                        }
                                    })
                                }
                            })
                        }
                    }
                });
            },




            // 递归判断子节点
            checkAreaTree(areasData, areas,type) {
                let that = this;
                areasData.forEach(function (p) {
                    if (that.hasArea(p, areas,type)) {
                        if(p.addrLevel==0||p.addrLevel==1){
                            //层级表示第一层级，第二层级不用勾选
                            p.checked = false;
                        }else{
                            p.checked = true;
                        }
                    } else {
                        p.checked = false;
                    }
                    if (p.children && p.children.length > 0) {
                        that.checkAreaTree(p.children, areas,type);
                    }
                });
            },

            // 判断渠道授权区域节点勾选
            hasArea(p, areas,type) {
                let flag = false;
                for (let i = 0; i < areas.length; i++) {
                    if ((p.value === areas[i].code)&&areas[i].businessType==type) {
                        flag = true;
                        break;
                    }
                }
                if (flag) {
                    return true;
                }
                return false;
            },

            //授权车型
            getCarsTreeList(){
                let param = {
                    type:this.basicTypeForm.carType,
                }
                getBrandTree(param).then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        // 仅展开指定级数 默认一级
                        let expandLevel = this.carLevel;
                        res.data.forEach(function (e) {
                            if (expandLevel == "0") {
                                if (e.carLevel === "0") {
                                    e.expand = true;
                                }
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (c.carLevel === "0") {
                                            c.expand = false;
                                        }
                                    });
                                }
                            } else {
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (expandLevel == 0) {
                                            if (c.carLevel === "1") {
                                                c.expand = false;
                                            }
                                        }
                                    });
                                }
                            }
                        });
                        this.carsData= deepClone(res.data);
                        this.carsDataOld = deepClone(res.data);
                    }
                });
            },
            // 递归判断子节点
            checkCarsTree(carsData, cars,type) {
                let that = this;
                carsData.forEach(function (p) {
                    if (that.hasCars(p, cars,type)=="0") {
                        p.checked = false;
                    }else if(that.hasCars(p, cars,type)=="1") {
                        p.checked = true;
                    }else if(that.hasCars(p, cars,type)=="2"){
                        if(p.carLevel=="0"){
                            p.checked = false;
                        }else{
                            p.checked = true;
                        }
                    }else{
                        if(p.carLevel=="0" || p.carLevel=="1" ){
                            p.checked = false;
                        }else{
                            p.checked = true;
                        }
                    }
                    if (p.children && p.children.length > 0) {
                        that.checkCarsTree(p.children, cars,type);
                    }
                });
            },
            checkOldCarsTree(carsData, cars,type) {
                let that = this;
                carsData.forEach(function (p) {
                    if (that.hasCars(p, cars,type)=="0") {
                        p.checked = false;
                    }else if(that.hasCars(p, cars,type)=="1") {
                        p.checked = true;
                    }else if(that.hasCars(p, cars,type)=="2"){
                        if(p.carLevel=="0"){
                            p.checked = false;
                        }else{
                            p.checked = true;
                        }
                    }else{
                        if(p.carLevel=="0" || p.carLevel=="1" ){
                            p.checked = false;
                        }else{
                            p.checked = true;
                        }
                    }
                    if (p.children && p.children.length > 0) {
                        that.checkCarsTree(p.children, cars,type);
                    }
                });
            },
            //判断授权车型节点勾选
            hasCars(p, cars,type) {
                let flag = "0";
                for (let i = 0; i < cars.length; i++) {

                    if (p.code === cars[i].code && cars[i].code=="00" &&  cars[i].indeterminate=="false" && cars[i].businessType===type ) {
                        //表示一级品牌名称非半选状态：即为全选状态，数据库只有一笔数据
                        flag="1";
                        if(cars[i].indeterminate=="false"){
                            p.indeterminate=false;
                        }else{
                            p.indeterminate=true;
                        }
                        break;
                    }else if (p.code === cars[i].code &&  cars[i].indeterminate=="false" && cars[i].businessType===type) {
                        //表示二级品牌非半选状态：即为全选状态，数据库只有一笔数据
                        flag = "2";
                        if(cars[i].indeterminate=="false"){
                            p.indeterminate=false;
                        }else{
                            p.indeterminate=true;
                        }
                        break;
                    }else if (p.code === cars[i].code && cars[i].businessType===type){
                        //表示三级品牌非半选状态：即为全选状态，数据库只有一笔数据
                        flag = "3";
                        p.indeterminate=true;
                        break;
                    }
                }

                return flag;
            },
            checkAllNewCar(v){
                let param = {};
                if(this.basicTypeForm.carType ==""){
                    param = {
                        type:[],
                    }
                }else{
                    param = {
                        type:this.basicTypeForm.carType,
                    }
                }
                getBrandTree(param).then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        // 仅展开指定级数 默认一级
                        let expandLevel = this.carLevel;
                        res.data.forEach(function (e) {
                            if (expandLevel == "0") {
                                if (e.carLevel === "0") {
                                    e.expand = true;
                                }
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (c.carLevel === "1") {
                                            c.expand = false;
                                        }
                                    });
                                }
                            } else {
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (expandLevel == 0) {
                                            if (c.carLevel === "1") {
                                                c.expand = false;
                                            }
                                        }
                                    });
                                }
                            }
                        });
                        let carsDataSearchTemp = deepClone(res.data);
                        if(v!=null && v!="" && v!= undefined){
                            //根据渠道id查询授权车型
                            getNewVehicleById(v).then(resCars => {
                                this.loading = false;
                                if (resCars.code === "0000") {
                                    let cars = resCars.data;
                                    if(cars.length>0){
                                        //新车
                                        this.checkCarsTree(carsDataSearchTemp, cars,"01");
                                        this.carsData= carsDataSearchTemp;
                                    }else{
                                        this.carsData= res.data;
                                    }
                                }
                            })
                        }else{
                            this.carsData= res.data;
                        }
                    }
                });
            },

            checkAllOldCar(v){
                let param = {};
                if(this.basicTypeForm.carTypeOld ==""){
                    param = {
                        type:[],
                    }
                }else{
                    param = {
                        type:this.basicTypeForm.carTypeOld,
                    }
                }
                getBrandTree(param).then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        // 仅展开指定级数 默认一级
                        let expandLevel = this.carLevel;
                        res.data.forEach(function (e) {
                            if (expandLevel == "0") {
                                if (e.carLevel === "0") {
                                    e.expand = true;
                                }
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (c.carLevel === "1") {
                                            c.expand = false;
                                        }
                                    });
                                }
                            } else {
                                if (e.children && e.children.length > 0) {
                                    e.children.forEach(function (c) {
                                        if (expandLevel == "0") {
                                            if (c.carLevel === "1") {
                                                c.expand = false;
                                            }
                                        }
                                    });
                                }
                            }
                        });
                        let carsDataOldSearchTemp = deepClone(res.data);
                        if(v!=null && v!="" && v!= undefined){
                            //根据渠道id查询授权车型
                            getOldVehicleById(v).then(resCars => {
                                this.loading = false;
                                if (resCars.code === "0000") {
                                    let cars = resCars.data;
                                    if(cars.length>0){
                                        //二手车
                                        this.checkOldCarsTree(carsDataOldSearchTemp, cars,"02");
                                        this.carsDataOld=carsDataOldSearchTemp;
                                    }else{
                                        this.carsDataOld= res.data;
                                    }
                                }
                            })
                        }
                    }
                });
            },

            changeSort(e) {
                this.searchForm.sort = e.key;
                this.searchForm.order = e.order;
                if (e.order === "normal") {
                    this.searchForm.order = "";
                }
                this.getAreaList();
            },

            showSelect(e) {
                this.selectList = e;
                this.selectCount = e.length;
            },

            changePage(v) {
                this.searchForm.pageNumber = v;
                this.getAreaList();
                this.clearSelectAll();
            },
            changePageSize(v) {
                this.searchForm.pageSize = v;
                this.getAreaList();
            },
            clearSelectAll() {
                this.$refs.table.selectAll(false);
            },


            //汇款对象数据字典
            paymentObjectType() {
                let param = {
                    type: "paymentObject"
                }
                getDictDataByType(param.type).then(res => {
                    if (res.code === "0000") {
                        this.paymentObjectList = res.data;
                    }
                });
            },

            //从父页面获取合作商id
            getOldChannelId2(v){
                this.basicTypeForm.oldChannelId=v;
                this.basicTypeForm.channelId=v;
            },
            //审核页面控制经纬度显示开关
            showRange(){
                this.showRangeSwitch=true;
            },

            //有效期表单验证是否生效
            /*verifyLimitDate(){

                if(this.basicTypeForm.temporaryLimitPut !="" && this.basicTypeForm.temporaryLimitPut !=null && this.basicTypeForm.temporaryLimitPut !=undefined){
                    this.basicTypeFormValidate.limitPutTime.unshift({ required: true, message: "有效期不能为空", trigger: "blur",type:"date"})
                }else{
                    this.basicTypeFormValidate.limitPutTime=[];
                }
                console.log(this.basicTypeFormValidate.limitPutTime)
                if(this.basicTypeForm.temporaryLimitPledge !=""){
                    this.basicTypeFormValidate.limitPledgeTime.unshift({ required: true, message: "有效期不能为空", trigger: "blur",type:"date"})
                }else{
                    this.basicTypeFormValidate.limitPledgeTime.shift();
                }
                if(this.basicTypeForm.temporaryLimitPutOld !=""){
                    this.basicTypeFormValidate.limitPutTimeOld.unshift({ required: true, message: "有效期不能为空", trigger: "blur",type:"date"})
                }else{
                    this.basicTypeFormValidate.limitPutTimeOld.shift();
                }
                if(this.basicTypeForm.temporaryLimitPledgeOld !=""){
                    this.basicTypeFormValidate.limitPledgeTimeOld.unshift({ required: true, message: "有效期不能为空", trigger: "blur",type:"date"})
                }else{
                    this.basicTypeFormValidate.limitPledgeTimeOld.shift();
                }
            },*/

            //控制二手车是否禁用
            carBusinessType(){
                console.log("选择车辆类型")
                console.log(this.basicTypeForm.businessType)
               let type = this.basicTypeForm.businessType;
                if(type.indexOf("01") > -1 && type.indexOf("02") > -1){
                    //新车二手车全部打开
                    this.showGroupNewCar="1";
                    this.showGroupOldCar="1";
                    /*this.viewNewCar="1";
                    this.viewOldCar="1";
                    this.showNewCar="1";
                    this.showOldCar="0";*/
                    //新车权限
                    this.isNewCarRole="1"
                    //二手车权限
                    this.isOldCarRole="1"
                }else if(type.indexOf("01") > -1 && type.indexOf("02") == -1){

                        //新车打开
                        this.showGroupNewCar="1";
                        this.showGroupOldCar="0";
                       /* this.viewNewCar="1"
                        this.viewOldCar="0"
                        this.showNewCar="1";
                        this.showOldCar="0";*/
                        //新车权限
                        this.isNewCarRole="1"
                        //二手车权限
                        this.isOldCarRole="0"
                }else if(type.indexOf("01") == -1 && type.indexOf("02") > -1){
                        //二手车打开
                        this.showGroupOldCar="1";
                        this.showGroupNewCar="0";
                        /*this.viewNewCar="0"
                        this.viewOldCar="1"
                        this.showNewCar="0";
                        this.showOldCar="1";*/
                        //新车权限
                        this.isNewCarRole="0"
                        //二手车权限
                        this.isOldCarRole="1"
                }else{
                    this.showGroupNewCar="0";
                    this.showGroupOldCar="0";
                   /* this.viewNewCar="0"
                    this.viewOldCar="0"
                    this.showNewCar="0";
                    this.showOldCar="0";*/
                    //新车权限
                    this.isNewCarRole="0"
                    //二手车权限
                    this.isOldCarRole="0"
                }

                let param ={
                    newCarRole:this.isNewCarRole,
                    oldCarRole:this.isOldCarRole
                }
                vueEvent.$emit('to-directCardealerAccountInfo',param)
            },

            //根据合作商id查询相关的信息
            getChannelInfoById(v){
                let id = this.basicTypeForm.channelId;
                console.log(id,"所选渠道id")
                console.log(this.basicTypeForm.carType)
                console.log(this.basicTypeForm.carTypeOld)
                /*if(id=="" || id==undefined || id== null){
                    /!*this.formValidate.salesMan=[];
                    this.personRelCardealerSwitch="0";*!/
                    return;
                };
                //获取当前合作商下面的所有业务员
                if(v != -1){
                    this.basicTypeForm.customerManagerOld="";
                    this.basicTypeForm.customerManager="";
                    this.basicTypeForm.carType=[];
                    this.basicTypeForm.carTypeOld=[];
                }*/
                console.log(this.basicTypeForm.carType)
                console.log(this.basicTypeForm.carTypeOld)
                console.log("-----")
                let newCar ="01";
                let oldCar ="02";
                getAllSaleManByChannelId(id,newCar).then(res => {
                    if (res.code === "0000") {
                        this.salesManData=res.data;
                    }
                });
                getAllSaleManByChannelId(id,oldCar).then(res => {
                    if (res.code === "0000") {
                        this.salesManDataOld=res.data;
                    }
                });
                getChannelBaseInfo(id).then(res => {
                    if (res.code === "0000") {
                        let paymentObject = res.data[0].paymentObject;
                        if(paymentObject == "0"){
                            //收款对象为主体,账号信息可选
                            this.accountSwitch="0";
                        }else{
                            //收款账号为车商,账号信息默认为有并且不可变
                            this.accountSwitch="1";
                            this.basicTypeForm.accountInfo = "1"
                        }
                        let type =  res.data[0].businessType;
                        console.log(type,"业务类型")
                        if(type.indexOf("01") > -1 && type.indexOf("02") > -1){
                            //新车二手车都可选
                            this.oldCar=false;
                            this.newCar=false;
                        }else if(type.indexOf("01") > -1 && type.indexOf("02") == -1){
                                //新车打开
                                this.oldCar=true;
                                this.newCar=true;
                                this.basicTypeForm.businessType=["01"];

                                //新车打开
                                this.showGroupNewCar="1";
                                this.showGroupOldCar="0";
                                /* this.viewNewCar="1"
                                 this.viewOldCar="0"
                                 this.showNewCar="1";
                                 this.showOldCar="0";*/
                                //新车权限
                                this.isNewCarRole="1"
                                //二手车权限
                                this.isOldCarRole="0"
                        }else if(type.indexOf("02") > -1 && type.indexOf("01") == -1){
                                //二手车打开
                                this.oldCar=true;
                                this.newCar=true;
                                this.basicTypeForm.businessType=["02"];
                                //二手车打开
                                this.showGroupOldCar="1";
                                this.showGroupNewCar="0";
                                /*this.viewNewCar="0"
                                this.viewOldCar="1"
                                this.showNewCar="0";
                                this.showOldCar="1";*/
                                //新车权限
                                this.isNewCarRole="0"
                                //二手车权限
                                this.isOldCarRole="1"
                            }
                    }
                    this.carBusinessType();
                });

                //获取所选的渠道车辆类型
                getChannelRiskInfoById(id).then(resRisk => {
                    if (resRisk.code === "0000") {
                        let str = JSON.stringify(resRisk.data);
                        let channelRiskInfoTemp = JSON.parse(str);
                        channelRiskInfoTemp.forEach((item, i) => {
                            //新车
                            if (item.businessType == "01") {
                                let carType1 = item.carType.split(',');
                                console.log(carType1)
                                console.log("-------------------")
                                if (carType1.indexOf("00") == -1) {
                                    this.businessTypeSwitch0 = "0"
                                }
                                if (carType1.indexOf("01") == -1) {
                                    this.businessTypeSwitch1 = "1"
                                }
                                if (carType1.indexOf("02") == -1) {
                                    this.businessTypeSwitch2 = "2"
                                }
                                if (carType1.indexOf("03") == -1) {
                                    this.businessTypeSwitch3 = "3"
                                }
                            } else {
                                let carType2 = item.carType.split(',');
                                if (carType2.indexOf("00") == -1) {
                                    this.carTypeSwitch0 = "0"
                                }
                                if (carType2.indexOf("01") == -1) {
                                    this.carTypeSwitch1 = "1"
                                }
                                if (carType2.indexOf("02") == -1) {
                                    this.carTypeSwitch2 = "2"
                                }
                                if (carType2.indexOf("03") == -1) {
                                    this.carTypeSwitch3 = "3"
                                }
                            }
                        })

                    }
                    /*if(v != -1){
                        this.basicTypeForm.carType=[];
                        this.basicTypeForm.carTypeOld=[];
                    }*/
                })

            },

            //账户页面的提交
            submitToCase(){
                let channelId = this.basicTypeForm.id;
                getChannelBaseInfo(channelId).then(res => {
                    if (res.code === "0000") {
                        this.basicTypeForm.id = res.data[0].id;
                        this.basicTypeForm.channelCode = res.data[0].channelCode;
                        this.basicTypeForm.channelFullName = res.data[0].channelFullName;
                        this.basicTypeForm.onlineDate = res.data[0].onlineDate;
                        this.basicTypeForm.socUniCrtCode = res.data[0].socUniCrtCode;
                        this.basicTypeForm.legalPerson = res.data[0].legalPerson;
                        this.basicTypeForm.legalPersonIdCard = res.data[0].legalPersonIdCard;
                        this.basicTypeForm.legalPersonTel = res.data[0].legalPersonTel;
                        this.basicTypeForm.cardealType = res.data[0].carDealType;
                        this.basicTypeForm.accountInfo = res.data[0].accountInfo;
                        this.basicTypeForm.actualController = res.data[0].actualController;
                        this.basicTypeForm.actualControllerTel = res.data[0].actualControllerTel;
                        this.basicTypeForm.actualControllerIdCard = res.data[0].actualControllerIdCard;
                        this.basicTypeForm.channelAdmin = res.data[0].channelAdmin;
                        this.basicTypeForm.channelAdminTel = res.data[0].channelAdminTel;
                        this.basicTypeForm.channelAdminMail = res.data[0].channelAdminMail;
                        this.basicTypeForm.longitude = res.data[0].longitude;
                        this.basicTypeForm.latitude = res.data[0].latitude;
                        this.basicTypeForm.longitudeLatitudeRange = res.data[0].longitudeLatitudeRange;
                        this.basicTypeForm.businessArea = res.data[0].businessArea;
                        this.basicTypeForm.paymentObject = res.data[0].paymentObject;
                        this.basicTypeForm.registrationDate = res.data[0].registrationDate;
                        this.basicTypeForm.channelBelong = res.data[0].channelBelong;
                        this.basicTypeForm.hierarchy = res.data[0].hierarchy;
                        this.basicTypeForm.channelAdminIdCard = res.data[0].channelAdminIdCard;
                        this.OldStatus = res.data[0].channelStatus;
                        if (res.data[0].registeredCapital) {
                            this.basicTypeForm.registeredCapital = res.data[0].registeredCapital + "";
                        }
                        if (res.data[0].assetLiabilityRatio) {
                            this.basicTypeForm.assetLiabilityRatio = res.data[0].assetLiabilityRatio + "";
                        }
                        if (res.data[0].businessLife) {
                            this.basicTypeForm.businessLife = res.data[0].businessLife + "";
                        }
                        if (res.data[0].operatingProfit) {
                            this.basicTypeForm.operatingProfit = res.data[0].operatingProfit + "";
                        }
                        if (res.data[0].achievement) {
                            this.basicTypeForm.achievement = res.data[0].achievement + "";
                        }
                        if (res.data[0].subscribedCapital) {
                            this.basicTypeForm.subscribedCapital = res.data[0].subscribedCapital + "";
                        }
                        if (res.data[0].netAssetValue) {
                            this.basicTypeForm.netAssetValue = res.data[0].netAssetValue + "";
                        }
                        if (res.data[0].proGrowthRate) {
                            this.basicTypeForm.proGrowthRate = res.data[0].proGrowthRate + "";
                        }
                        if (res.data[0].saleIncreaseRate) {
                            this.basicTypeForm.saleIncreaseRate = res.data[0].saleIncreaseRate + "";
                        }
                        if (res.data[0].currentRatio) {
                            this.basicTypeForm.currentRatio = res.data[0].currentRatio + "";
                        }
                        this.basicTypeForm.longitudeLatitudeSwitch = res.data[0].longitudeLatitudeSwitch;
                        this.basicTypeForm.personRelCardealerSwitch = res.data[0].personRelCardealerSwitch;
                        this.basicTypeForm.choiceCardealerSwitch = res.data[0].choiceCardealerSwitch;
                        this.basicTypeForm.businessType = res.data[0].businessType.split(',');
                        this.basicTypeForm.gpsVendorAuthor = res.data[0].gpsVendorAuthor.split(',');
                        this.basicTypeForm.gpsInstalMode = res.data[0].gpsInstalMode;

                        let channelAddressValue = [];
                        channelAddressValue[0] = res.data[0].channelProvince;
                        channelAddressValue[1] = res.data[0].channelCity;
                        this.basicTypeForm.channelAddressValue = channelAddressValue;
                        this.basicTypeForm.channelAddressDetail = res.data[0].channelAddress;

                        //开票信息
                        this.invoiceForm.taxpayerType = res.data[0].taxpayerType;
                        this.invoiceForm.taxpayerIdNumber = res.data[0].taxpayerIdNumber;
                        this.invoiceForm.invoiceTelNumber = res.data[0].invoiceTelNumber;
                        this.invoiceForm.invoiceAddress = res.data[0].invoiceAddress;
                        this.invoiceForm.openingBank = res.data[0].openingBank;
                        this.invoiceForm.bankAccount = res.data[0].bankAccount;
                        this.invoiceForm.taxRate = res.data[0].taxRate;

                        this.basicSubmit();
                        console.log("**")
                       /* let channelInfo = this.basicTypeForm;
                        this.$emit('passmsg', channelInfo)*/
                    }
                });


            },

            //控制签放额度是否必输
            checkLimitPut(){
                var reg = /^\d+(\.\d+)?$/;
                let isLimitPut = this.basicTypeForm.isLimitPut;
                let limitPut = this.basicTypeForm.limitPut;
                if(isLimitPut=="0"){
                    this.$refs.basicTypeForm.fields.forEach(function (e) {
                        if (e.prop == 'limitPut' && (limitPut==""||limitPut==null||limitPut==undefined)) {
                            e.validateMessage="";
                        }
                    })
                };

                let isLimitPledge = this.basicTypeForm.isLimitPledge;
                let limitPledge = this.basicTypeForm.limitPledge;
                if(isLimitPledge=="0"){
                    this.$refs.basicTypeForm.fields.forEach(function (e) {
                        if (e.prop == 'limitPledge'&& (limitPledge==""||limitPledge==null||limitPledge==undefined)) {
                            e.validateMessage="";
                        }
                    })
                }

                let isLimitPutOld = this.basicTypeForm.isLimitPutOld;
                let limitPutOld = this.basicTypeForm.limitPutOld;
                if(isLimitPutOld=="0"){
                    this.$refs.basicTypeForm.fields.forEach(function (e) {
                        if (e.prop == 'limitPutOld' && (limitPutOld==""||limitPutOld==null||limitPutOld==undefined)) {
                            e.validateMessage="";
                        }
                    })
                };

                let isLimitPledgeOld = this.basicTypeForm.isLimitPledgeOld;
                let limitPledgeOld = this.basicTypeForm.limitPledgeOld;
                if(isLimitPledgeOld=="0"){
                    this.$refs.basicTypeForm.fields.forEach(function (e) {
                        if (e.prop == 'limitPledgeOld'&& (limitPledgeOld==""||limitPledgeOld==null||limitPledgeOld==undefined)) {
                            e.validateMessage="";
                        }
                    })
                }
            },

            getAllSaleManByChannelId(){
                //获取当前合作商下面的所有业务员
                let newCar ="01";
                let oldCar ="02";
                getAllSaleManByChannelId(this.basicTypeForm.channelId,newCar).then(res => {
                    if (res.code === "0000") {
                        this.salesManData=res.data;
                    }
                });
                getAllSaleManByChannelId(this.basicTypeForm.channelId,oldCar).then(res => {
                    if (res.code === "0000") {
                        this.salesManDataOld=res.data;
                    }
                });
            },

            //优质等级控制有效期
            checkQualityGrade(){
                let qualityGrade = this.basicTypeForm.qualityGrade;
                let validDate = this.basicTypeForm.validDate;
                if(qualityGrade=="5"){
                    this.$refs.basicTypeForm.fields.forEach(function (e) {
                        if (e.prop == 'validDate') {
                            e.validateMessage="";
                            e.validateState="";
                        }
                    })
                };

                let qualityGradeOld = this.basicTypeForm.qualityGradeOld;
                let validDateOld = this.basicTypeForm.validDateOld;
                if(qualityGradeOld=="5"){
                    this.$refs.basicTypeForm.fields.forEach(function (e) {
                        if (e.prop == 'validDateOld') {
                            e.validateMessage="";
                            e.validateState="";
                        }
                    })
                };
            },

            //优质等级字典处理
            qualityGradeType() {
                let param = {
                    type: "qualityGrade"
                }
                getDictDataByType(param.type).then(res => {
                    if (res.code === "0000") {
                        this.qualityGradeList = res.data;
                    }
                });
            },
            //GPS厂商字典处理
            gpsSupplier() {
                let param = {
                    type: "gpsManufacturer"
                }
                getDictDataByType(param.type).then(res => {
                    if (res.code === "0000") {
                        this.gpsvendorauthorList = res.data;
                    }
                });
            },
            //GPS安装方式字典处理
            gpsinstalmode() {
                let param = {
                    type: "gpsinstalmode"
                }
                getDictDataByType(param.type).then(res => {
                    if (res.code === "0000") {
                        this.gpsinstalmodeList = res.data;
                    }
                });
            },


            // 查询数据字典
            initDataDic() {
                this.paymentObjectType();
                this.qualityGradeType();
                this.gpsinstalmode();
                this.gpsSupplier();
            },

            // 地图弹窗
            openMapModal(){
                let address = this.mapLocation
                let detial = this.basicTypeForm.channelAddressDetail
                console.log(address,detial);
                this.mapModal = true;
            },
            // 确认经纬度
            confirmLngLat(data){
                console.log('选择的经纬度为：',data);
                this.mapModal = false;
                if(data && data.latitude && data.longitude){
                    //this.basicTypeForm = Object.assign({},this.basicTypeForm,data)
                    this.basicTypeForm.latitude=data.latitude.toString();
                    this.basicTypeForm.longitude=data.longitude.toString();
                }
            },
            closeMapModel(){
                this.mapModal = false;
            },
            onBlurLocation(){
                this.$refs.basicTypeForm.validateField('channelAddressDetail',(e) => {
                    console.log('channelAddressDetail',e,typeof e);
                    if(!e) {
                        this.mapAddress = this.basicTypeForm.channelAddressDetail;
                        if(this.mapLocation) {
                            this.canOpenMapModal = true;
                            this.openMapModal();
                        }
                    }

                })

            },
            onChangeLocation(value, data){
                console.log(value, data);
                let str='';
                if(Array.isArray(data) && data.length){
                    data.forEach(ele =>{
                        str += (ele.label ? ele.label : '');
                    })
                    this.mapLocation = str;
                    if(this.mapAddress) {
                        this.canOpenMapModal = true;
                    }
                }
            },


            //反向解析省市地址
            getProvinceData() {
                let param = {level:"1",upperCode: "1"};

                getLocation(param).then(res => {
                    if(res.code === "0000"){
                        this.province=res.data;
                    }
                });
            },
            getCityData() {
                let param = {level:2,upperCode:''};
                getLocation(param).then(res => {
                    if (res.code == "0000") {
                        this.city=res.data;
                    }
                });
            },

            getDetailAddress1(registeredProvince,registeredCity){
                if(registeredProvince!="" && registeredCity!=""){
                    let province="";
                    let city="";
                    for(let i=0;i<this.province.length;i++){
                        if(this.province[i].value==registeredProvince){
                            province=this.province[i].label;
                        }
                    };
                    for(let i=0;i<this.city.length;i++){
                        if(this.city[i].value==registeredCity){
                            city=this.city[i].label;
                        }
                    };
                    this.mapLocation=province+city;
                }
            },

            checkdate(){
                if(this.basicTypeForm.temporaryLimitPut){
                    this.newCarDate1 = '1';
                }else{
                    this.newCarDate1 = '0';
                }
                if(this.basicTypeForm.temporaryLimitPledge){
                    this.newCarDate2 = '1';
                }else{
                    this.newCarDate2 = '0';
                }
                if(this.basicTypeForm.temporaryLimitPutOld){
                    this.oldCarDate1 = '1';
                }else{
                    this.oldCarDate1 = '0';
                }
                if(this.basicTypeForm.temporaryLimitPledgeOld){
                    this.oldCarDate2 = '1';
                }else{
                    this.oldCarDate2 = '0';
                }
            },
            changeGPS(){
                if(this.basicTypeForm.gpsVendorAuthor.indexOf("all") > -1){
                    this.basicTypeForm.gpsVendorAuthor=["all"]
                }
            }


        },

        created() {
        },
        mounted() {
            this.init();
        },
    }
</script>

<style>
    .basis-info .ivu-icon-ios-search:before{
        font-size: 18px;
        position: absolute;
        right: 5px;
    }
    .basis-info .ivu-input[disabled]{
        color: black;
    }
    .basis-info span.ivu-select-selected-value{
        color: black;
    }
    .basis-info .ivu-input-number-input[disabled]{
        color:black;
    }

    .s1 .ivu-select-dropdown-list {
            height:200px;
        }


</style>

